|
@@ -5,29 +5,11 @@
|
5
|
5
|
|
6
|
6
|
## Part 1 - Product
|
7
|
7
|
In the `test` folder, there is a `ProductTest` with most of the tested commented out.
|
8
|
|
- 1. Notice the word `Product` is red. That's because we need to create a new Class named `Product`. The file should be in `src/main/java/org.zipcoder.store`.
|
9
|
|
- - To make the test pass, create a new empty constructor with no parameter
|
10
|
|
- 2. Uncomment the second test, line 14 - 26.
|
11
|
|
- - Create a new constructor that takes a String for the product name
|
12
|
|
- 3. Continue to uncomment the test and make it pass
|
13
|
|
- 4. For the `get` and `set` test, you need to create a field and methods to get and set the field.
|
14
|
|
- - Ex:
|
15
|
|
-
|
16
|
|
- ```java
|
17
|
|
- public class Book {
|
18
|
|
- private String title;
|
19
|
|
-
|
20
|
|
- public void setTitle(String title){
|
21
|
|
- this.title = title;
|
22
|
|
- }
|
23
|
|
-
|
24
|
|
- public String getTitle() {
|
25
|
|
- return this.title;
|
26
|
|
- }
|
27
|
|
- }
|
28
|
|
- ```
|
29
|
|
- 5. Continue to uncomment the test and add code to make the test pass
|
30
|
|
- 6. For the product description, it should be in this format `title (Color: color, Size: size)`
|
|
8
|
+ 1. The first test `testConstruction_WithNoParams` checks to see if the `Product` class has an empty constructor. To test it, I created a new object with no parameter.
|
|
9
|
+ 2. The second test `testGetSetName` checks to see if you can set and get the name of the product. In order to make this pass, I added a `String` field called `name` (line 5). Then I added a getter method `getName` (line 18-20) and a setter method `setName(String name)` (line 23-25).
|
|
10
|
+ 3. The third test `testConstruction_WithName` checks if the `Product` class has a constructor that takes a String. Notice we can have more than one constructor. When I create a new Product with a string `new Product("T-shirt")`, I set that string to the field `name` so when I called `getName`, I get the string that I passed into the constructor.
|
|
11
|
+ 4. Continue to uncomment the test and write the code to make it pass
|
|
12
|
+ 5. For the product description, it should be in this format `title (Color: color, Size: size)`
|
31
|
13
|
- ex: `Hat (Color: Yellow, Size: LG)`
|
32
|
14
|
|
33
|
15
|
## Part 2 - Cart
|