|
@@ -2,6 +2,7 @@
|
2
|
2
|
* **Purpose** - to understand [classes](https://docs.oracle.com/javase/tutorial/java/concepts/class.html), [objects](https://docs.oracle.com/javase/tutorial/java/concepts/object.html) and [data encapsulation](https://en.wikipedia.org/wiki/Data_encapsulation).
|
3
|
3
|
* **Objective** - to create a cart with products and payment
|
4
|
4
|
|
|
5
|
+
|
5
|
6
|
## Part 1 - Product
|
6
|
7
|
In the `test` folder, there is a `ProductTest` with most of the tested commented out.
|
7
|
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,7 +10,8 @@ In the `test` folder, there is a `ProductTest` with most of the tested commented
|
9
|
10
|
2. Uncomment the second test, line 14 - 26.
|
10
|
11
|
- Create a new constructor that takes a String for the product name
|
11
|
12
|
3. Continue to uncomment the test and make it pass
|
12
|
|
- 4. For the `get` and `set` test, you need to create a field and methods to get and set the field. Ex:
|
|
13
|
+ 4. For the `get` and `set` test, you need to create a field and methods to get and set the field.
|
|
14
|
+ - Ex:
|
13
|
15
|
|
14
|
16
|
```java
|
15
|
17
|
public class Book {
|
|
@@ -44,7 +46,8 @@ A cart has an array of Product.
|
44
|
46
|
|
45
|
47
|
## Part 3 - CreditCard
|
46
|
48
|
The goal of this exercise is to know how to create and test a class.
|
47
|
|
- 1. Create a new class called `CreditCard`
|
|
49
|
+ 1. In the test folder, create a new test class called `CreditCardTest`
|
|
50
|
+ 2. Create a new class called `CreditCard`
|
48
|
51
|
2. Create a test case to get and set the `cardHolderName` of the type `String`
|
49
|
52
|
- Create getter and setter methods in the `CreditCard` class
|
50
|
53
|
- Add a field called cardHolderName
|