Java Project named Bakery that includes two classes: Pie and PieTester. Your class must include an overloaded constructor that takes all three attributes as arguments, setters, and getters and the two methods shown in the UML diagram. The PieTester class will include a header with your name: “From the kitchen of A. Ramirez,” generate 3 pies using the default constructor and using the setter you will provide their attributes. Then, it will generate additionally 3 pies using the overloaded constructor. Using the showYourself() method it will display the 6 pies. Then, it will use the increasePrice() method to increase all six pies prices by 10% plus the last digit of your student number, i.e., if your last digit is 4, then it will increase it by 14%. Finally, use the showYourself() method again to display the 6 pies with their new prices.
PieTester.
Your class must include an overloaded constructor that takes all three attributes as arguments,
setters, and getters and the two methods shown in the UML diagram.
The PieTester class will include a header with your name: “From the kitchen of A. Ramirez,”
generate 3 pies using the default constructor and using the setter you will provide their attributes.
Then, it will generate additionally 3 pies using the overloaded constructor. Using the
showYourself() method it will display the 6 pies. Then, it will use the increasePrice() method to
increase all six pies prices by 10% plus the last digit of your student number, i.e., if your last digit
is 4, then it will increase it by 14%. Finally, use the showYourself() method again to display the 6
pies with their new prices.
Algorithm for Bakery Project
1. Create a class named Pie with the following attributes:
- UPC (String)
- Name (String)
- Price (double)
2. Define a default constructor for the Pie class:
- Initialize UPC, Name, and Price to default values (empty string and 0.0).
3. Define an overloaded constructor for the Pie class that takes UPC, Name, and Price as arguments.
- Initialize the attributes with the provided values.
4. Implement getters and setters for the UPC, Name, and Price attributes.
5. Define a method in the Pie class named showYourself:
- Display the UPC, Name, and Price of the pie.
6. Define a method in the Pie class named increasePrice that takes a percentage as an argument:
- Calculate the price increase by applying the percentage.
- Update the Price attribute with the new price.
7. Create a class named PieTester.
8. Inside the PieTester class:
- Print "From the kitchen of A. Ramirez" as a header.
9. Create three Pie objects using the default constructor and three using the overloaded constructor:
- Initialize the pie objects with different UPC, Name, and Price values.
10. Display the information of all six pies using the showYourself method.
11. Calculate the price increase percentage as 10% plus the last digit of your student number.
12. Apply the increasePrice method to all six pies, increasing their prices using the calculated percentage.
13. Display the updated information of all six pies using the showYourself method.
End of Algorithm.
Step by step
Solved in 4 steps with 3 images