Biscuit Factory
+------------------------------------+ +-------------------+
| + Biscuit | | + BiscuitFactory |
+------------------------------------+ +-------------------+
| -getNumberOfBiscuits : int | | |
| -weight : int | 0..* 1 +-------------------+
| -brand : String |---------------| +main() : void |
| -maker : String | +-------------------+
+------------------------------------+
| +Biscuit() |
| +Biscuit(String, String, int) |
| +getBrand() : String |
| +setBrand(String) : void |
| +getNumberOfBiscuits() : int |
| +getWeight() : int |
| +setWeight(int) : void |
| +getMaker() : String |
| +setMaker(String) : void |
| +toString() : String |
| +isOutOfDate() : boolean |
+------------------------------------+
- Create a biscuit (with object ref biscuitOne) using the default constructor.
- Use the set methods to set their details to Kimberly, Jacobs (maker), 15
- Use the toString to output the details for biscuitOne (output as shown below).
- Create another biscuit (with object ref biscuitTwo) using the overloaded constructer (McVities, Digestive, 20).
- Use the toString method to output the details for biscuitTwo
- Change the details for biscuitTwo using set methods to (Cadburys, Wholewheat, 25) and output again using toString().
- Output the count of the number of biscuits created using getNumberOfBiscuits
Console Output:
Biscuit [Maker=Jacobs, brand=Kimberly, weight=15]
Biscuit [Maker=McVities, brand=Digestive, weight=20]
Biscuit [Maker=Cadburys, brand=Wholewheat, weight=25]
2