Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem Description Help Darryl keep track of his warehouse of paper products! Due to the new Computer software poorly written in C and his

imageimageimageimageimageimage

Problem Description Help Darryl keep track of his warehouse of paper products! Due to the new Computer software poorly written in C and his boss Michael making it impossible for him to work in the warehouse by adding in his golden tickets to random shipments, Darryl is unable to keep track of his stock in the warehouse. Help him by rewriting his software in clean Java! Solution Description You will implement 5 classes: PaperProduct.java, Photo Paper.java, Golden Ticket.java, Discounted Paper.java, and Warehouse.java Note: 1. All variables should be inaccessible from other classes and must require an instance to be accessed through, unless specified otherwise. 2. All methods should be accessible from everywhere and must require an instance to be accessed through, unless specified otherwise. 3. Use constructor and method chaining whenever possible! Ensure that your constructor chaining helps you reduce code reusage! 4. Reuse code when possible and helper methods are optional. 5. All floating point values must be printed to only 2 decimal places, with rounding. 6. Make sure to add all Javadoc comments to your methods and classes! PaperProduct.java This file will store details about a paper product in general. We will create multiple child classes to specialize these products. Variables: . name a String variable representing the name of the Product at a given instance. An invalid value should default to "A4". The value is invalid if name is an empty String or null. This value cannot be changed once set. numberOfSheets - an int representing the number of the sheets of paper present in this product. An invalid value should always be set to 500. The value is invalid if it is negative. weightOfUnit Sheet - a double representing the weight, in grams, of one sheet of the paper product at a given instance. An invalid value should always be set to 0.25. The value is invalid if it is negative. This value cannot be changed once set. totalProductsToShip - an int representing the total number of Paper Product that can be shipped. This variable should be shared across multiple instances. It must have an initial value of 10. [Hint: This variable should only decrease when you run your code and should not be negative] COST PER GRAM-a constant representing the cost of any product per gram, with the value 0.025. This variable should be accessible everywhere. Constructor(s): A constructor that takes in name, numberOfSheets, weight of Unit Sheet. A constructor that takes in name, numberOfSheets, and defaults weight of Unit Sheet to 0.25. A constructor that takes in name, and defaults number Of Sheets to 500 and weightOfUnit Sheet to 0.25. A copy constructor that deep copies all instance variables of the old object to the new object Methods: totalWeight () - returns the total weight of the Paper Product. total Cost () - returns the total cost of the Paper Product paperString() ship() Returns a String representing the Object Should return the String in the following format: " g of for $ " o Takes in a name of the company to ship to as a parameter o If total ProductsToShip does not equal 0, return the String: "Shipped g of for $ to ." o If total ProductsToShip equals 0, return the String: "Cannot ship any items, Warehouse is empty!" Make sure to update all relevant variables in this method (decrement the number of products to ship by 1) Getters for name, numberof Sheets, weightOfUnit Sheet, and totalProductsToShip Setter for numberof Sheets PhotoPaper.java This file will store details about the Photo Paper stock in the warehouse. It is a child class of PaperProduct. Variables: - glossiness a double representing the glossiness of the paper product in the range [0, 100]. If an invalid value is entered, this variable should default to 70. Constructor(s): A constructor that takes in name, numberOfSheets, weightOfUnit Sheet, glossiness. A constructor that takes in name, numberOfSheets and defaults glossiness to 70, and all other variables to their default in paper-product. A constructor that takes in name, and defaults glossiness to 70, and all other variables to their default in paper-product. A copy constructor that deep copies all instance variables of the old object to the new object Methods: photoString() Returns a String representing the Object. Should return the String in the following format: " glossy and g of for $ " shipPhoto () o Takes in a name of the company to ship to as a parameter If total ProductsToShip does not equal 0, return the String: "Paper is glossy. Shipped g of for $ to ." If total ProductsToShip is 0, then it should return the String: "Paper is glossy. Cannot ship any items, Warehouse is empty!" Make sure to update all relevant variables in this method. Keep in mind that the variables may be private in the super class, but they should be able to be modified through a publicly available method if chained correctly. Getter and setter for glossiness Reuse code if possible Golden Ticket.java This file will store details about the Golden Tickets that customers can use with the Discounted Stock. Variables: catchphrase a String object that represents the catchphrase printed on the ticket! An invalid value should default to "Congrats!". The value is invalid if catchphrase is an empty String or null. discount - a double representing the discount offered by the ticket, in percent, in the range (0, 25]. If an invalid value is entered, then this variable should default to 15.0. Constructor(s): A constructor that takes in catchphrase, discount. Methods: ticketString() Returns a String representing the object, with the given format: "Golden Ticket with a % discount! " Getters and setters for catchphrase and discount Discounted Paper.java This file will store details about the Discounted Paper stock in the warehouse. It is a child class of Paper Product. Variables: discount - a double representing the discount of the paper product, in percent, in the range (0, 50]. If an invalid value is entered, then this variable should default to 15.0. ticket a GoldenTicket object representing whether this product has a golden ticket attached to it. It has a default value of null. Constructor(s): A constructor that takes in name, numberOfSheets, weight Of Unit Sheet, discount, ticket. A constructor that takes in name, numberOfSheets, and defaults discount to 15, ticket to null, and all other variables to their default in PaperProduct. A constructor that takes in name, and defaults discount to 15, ticket to null, and all other variables to their default in Paper Product. A copy constructor that deep copies all instance variables of the old Object to the new Object Methods: discountedCost () Should calculate and return the total cost after the discount. If there is a golden ticket attached, apply the Golden Ticket discount to the discounted price. ship Discounted () Takes in a name of the company to ship to as a parameter If total ProductsToShip does not equal 0, return the String: Shipped g of for $ to . The total cost after the discount is ." If total ProductsToShip is 0, then it should return the String: "Cannot ship any items, Warehouse is empty! The total cost after the discount is ." Make sure to update all relevant variables in this method. ' Keep in mind that the variables may be private in the super class, but they should be able to be modified through a publicly available method if chained correctly. botherAccounting () Returns a String to representing the discounting of this product as an entry for the accounting department. It should return a String in the following format: "Discounted Paper Product: Original Cost: Final Cost: Original Discount: % Golden Ticket Discount: " If there is no Golden Ticket, then the Golden Ticket discount should be 0. Getters and setters for discount and ticket Reuse code if possible 331 Warehouse.java This Java file is a driver, meaning it will contain and run all the above classes! Use this to test your code. Create at least 2 Paper Products, 2 Dis LedPaper, 2 Photo Paper, and 1 GoldenTicket. Use the copy constructors at least once. Try modifying the objects to see if you have deep copied properly. Call the relevant ship methods on each of your Paper Product and its children's objects and print the results. Call botherAccounting () on all Discounted Paper and print the result. Reuse your code when possible. These tests and the ones on Gradescope are by no means comprehensive, so be sure to create your own! Submission To submit, upload the files listed below to the corresponding assignment on Gradescope: Paper Product.java Photo Paper.java Golden Ticket.java Discounted Paper.java Warehouse.java

Step by Step Solution

3.42 Rating (152 Votes )

There are 3 Steps involved in it

Step: 1

java The PaperProduct class represents a generic paper product public class PaperProduct private Str... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Global Marketing

Authors: Svend Hollensen

8th Edition

1292251808, 9781292251806

More Books

Students also viewed these Programming questions

Question

3. What is one brain location and mechanism for working memory?

Answered: 1 week ago

Question

5. Which types of memory are least impaired in H. M.?

Answered: 1 week ago