Problem Description Help Darryl keep track of his warehouse of paper products! Due to the new...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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: "<totalWeight>g of <name> for $<totalCost>" 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 <totalWeight>g of <name> for $<totalCost> to <Company>." 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: "<glossiness> glossy and <totalWeight>g of <name> for $<totalCost>" 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 <glossiness> glossy. Shipped <totalWeight>g of <name> for $<totalCost> to <Company>." If total ProductsToShip is 0, then it should return the String: "Paper is <glossiness> 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>% discount! <catchphrase>" • 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 <totalWeight>g of <name> for $<totalCost> to <Company>. The total cost after the discount is <discountedCost>." о о 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 <discountedCost>." 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: <original cost> Final Cost: <final cost> Original Discount: <original discount>% Golden Ticket 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 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: "<totalWeight>g of <name> for $<totalCost>" 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 <totalWeight>g of <name> for $<totalCost> to <Company>." 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: "<glossiness> glossy and <totalWeight>g of <name> for $<totalCost>" 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 <glossiness> glossy. Shipped <totalWeight>g of <name> for $<totalCost> to <Company>." If total ProductsToShip is 0, then it should return the String: "Paper is <glossiness> 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>% discount! <catchphrase>" • 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 <totalWeight>g of <name> for $<totalCost> to <Company>. The total cost after the discount is <discountedCost>." о о 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 <discountedCost>." 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: <original cost> Final Cost: <final cost> Original Discount: <original discount>% Golden Ticket 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
Expert Answer:
Answer rating: 100% (QA)
java The PaperProduct class represents a generic paper product public class PaperProduct private Str... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
Write a well-developed paragraph that compares/contrasts a character from Good Country People with a character from Seventeen Syllables.
-
The normal lens on a 35-mm camera has a focal length of 50.0 mm. Its aperture diameter varies from a maximum of 25 mm (f / 2) to a minimum of 3.0 mm (f / 16). Determine the resolution limit set by...
-
For the following exercises, graph the parabola, labeling the focus and the directrix. y 2 8x + 10y + 9 = 0
-
Reconsider Problem 56. Determine which oven should be purchased based on an incremental annual worth analysis. Data from problem 56 Octavia Bakery is planning to purchase one of two ovens. The...
-
The City of Green Meadows has had an employee pension fund for several years. The following is a trial balance for the fund at December 31, 2011, as well as several transactions that occurred during...
-
What does a Revenue Rulling do? Clarity and explain various provisions of the Code, in the opinion of the Treasury O Modify or reverse an IRS decision O Provide guidance of internal management...
-
The introduction of movie-streaming technology is an example of a: high-learning product fad convenience good fashion product low-learning product
-
What is the future value of $ 9 0 , 3 8 0 . 0 0 given an interest rate of 1 7 . 0 0 % compounded quarterly for 3 7 years?
-
In 1 9 6 0 , the average price for one - carat diamond was around $ 2 , 5 0 0 . Since then, the diamond price has increased to around $ 3 0 , 0 0 0 in 2 0 1 5 . If the price for one - carat diamond...
-
Tan-O-Rama is a local tanning salon. The following information reflects its number of appointments and total costs for the first half of the year: Month Appointments Number of Total Cost January 500...
-
You bought a $ 1 0 , 0 0 0 Par Value, 4 . 2 5 % Coupon, City of Boston bond, that matured on 5 / 0 3 / 2 0 4 2 when it was being quoted at 9 7 . Two years later you'll sell it when it's being quoted...
-
"If there is a shortage of flowers, their price will rise. The shortage will eventually disappear because the higher price will reduce demand and increase supply." Explain what's wrong with this...
-
02 <2;0sy2 IB f(xiy) = cla-z-y) %3D Otherwise and 3i, CoV(X.Y) find i C 36 pck.y) - (>x1y) (2x+4) a= 1, 2 : Y = 1,2 otheowise find the marginal probability tunctions Continous slandom vaoi able is...
-
What are the two components of a company's income tax provision? What does each component represent about a company's income tax provision?
-
You are a European preparing to negotiate with a Japanese firm for the first time. How would you prepare for the assignment if it is taking place: (a) In the Japanese headquarters; (b) In one of its...
-
Describe an industrial distributor. What types of products are marketed through an industrial distributor?
-
Discuss the benefits gained by adopting a matrix organizational structure.
-
Show that, in Theorem 19.17, the quadratic variation \(\langle Mangle_{t}\) is a \(\mathscr{G}_{t}\) stopping time.Direct calculation, use Lemma 19.16.c) and A. 15 Data From Theorem 19.17 19.17...
-
The proof of Theorem 19.29 uses, implicitly, the following beautiful result due to Skorokhod [239] which is to be proved: Lemma. Let \(b:[0, \infty) ightarrow \mathbb{R}\) be a continuous function...
-
We have seen in Lemma 19.27.a) that \(\operatorname{supp}\left[d L_{t}^{0}(\omega) ight] \subset\left\{t \geqslant 0: B_{t}(\omega)=0 ight\}\) for almost all \(\omega\). Show that...
Study smarter with the SolutionInn App