Skip to content

Commit

Permalink
Task association of Position test and minor fixes to Windowing system…
Browse files Browse the repository at this point in the history
… concept exercise (#604)

* Remove type declaration from introduction snippet

The concept of type declaration is introduced later. Also the
declaration is not necessary here for other reasons than type safety.

* Fix markdown syntax of concept introduction

* Specify code block as text in instructions

* Add hint on parameter positioning

* Move / reassign Position property test to task 4

* Apply automatic changes

---------

Co-authored-by: mk-mxp <[email protected]>
  • Loading branch information
mk-mxp and mk-mxp authored Jan 27, 2024
1 parent cd3c170 commit 1e05b8c
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 19 deletions.
6 changes: 2 additions & 4 deletions concepts/class-basics/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Door

Classes are instantiated with the `new` keyword, this allocates memory for the class instance and calls the classes constructor method.
Instantiated classes may be assigned to a variable.
To invoke the methods of a class instance, we can use the `->` access operator
To invoke the methods of a class instance, we can use the `->` access operator.

```php
<?php
Expand All @@ -49,7 +49,7 @@ class Car
$this->color = $color;
}

function getColor(): string
function getColor()
{
return $this->color;
}
Expand All @@ -59,5 +59,3 @@ $a_car = new Car("red");
$a_car->color; // => "red" by accessing the property
$a_car->getColor(); // => "red" by invoking the instance method
```


3 changes: 2 additions & 1 deletion exercises/concept/windowing-system/.docs/hints.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
## General

- Revisit the [Objects Concept][concept-class-basics] if needed to fresh up on the basics.
- Carefully read the instructions for the parameter positioning of `x`, `y`, `width`, and `height`. These are easily confused.

## 1. Define a ProgramWindow class

- Remember to use [class syntax][php-class] for this task.
- Define [properties][php-properties] by adding them to class declaration.
- Define [properties][php-properties] by adding them to the class declaration.

## 2. Define a constructor function for the ProgramWindow class

Expand Down
2 changes: 1 addition & 1 deletion exercises/concept/windowing-system/.docs/instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ In this exercise, you will be simulating a windowing based computer system.
You will create some windows that can be moved and resized.
The following image is representative of the values you will be working with below.

```
```text
╔════════════════════════════════════════════════════════════╗
║ ║
║ position::$x,_ ║
Expand Down
4 changes: 2 additions & 2 deletions exercises/concept/windowing-system/.docs/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Door

Classes are instantiated with the `new` keyword, this allocates memory for the class instance and calls the classes constructor method.
Instantiated classes may be assigned to a variable.
To invoke the methods of a class instance, we can use the `->` access operator
To invoke the methods of a class instance, we can use the `->` access operator.

```php
<?php
Expand All @@ -51,7 +51,7 @@ class Car
$this->color = $color;
}

function getColor(): string
function getColor()
{
return $this->color;
}
Expand Down
22 changes: 11 additions & 11 deletions exercises/concept/windowing-system/ProgramWindowTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,6 @@ public function testHasConstructorSettingInitialValues()
$this->assertEquals(800, $window->width);
}

/**
* @testdox assert Position class exists, with constructor, properties
* @task_id 3
*/
public function testPositionHasConstructorSettingInitialValues()
{
$position = new Position(30, 70);
$this->assertEquals(30, $position->y);
$this->assertEquals(70, $position->x);
}

/**
* @testdox assert Position class exists, with constructor, properties
* @task_id 3
Expand All @@ -109,6 +98,17 @@ public function testProgramWindowResize()
$this->assertEquals(2135, $window->width);
}

/**
* @testdox assert Position class exists, with constructor, properties
* @task_id 4
*/
public function testPositionHasConstructorSettingInitialValues()
{
$position = new Position(30, 70);
$this->assertEquals(30, $position->y);
$this->assertEquals(70, $position->x);
}

/**
* @testdox assert ProgramWindow::move function exists
* @task_id 4
Expand Down

0 comments on commit 1e05b8c

Please sign in to comment.