subject

The Product class has a productID and a price. It also has a method getProductID() as shown in the code below. public class Product{ private String productID; private double price; public Product(String productID, double price){ //implementation not shown } public boolean canReplace(Product p){ //implementation not shown } //other instance variables, constructors and methods are not shown}public class Widget extends Product{private String productionDate;public Widget(String id, String pd, double price){//to be implemented in part a}}A Widget is a Product and has a productID and price. The productID is a unique string for each product. No two productID's are the same. Given the following code, Product p1 = new Product("341-1101", 129.99);Product p2 = new Widget("82794-mach10q", "12/7", 89.99);Widget w1 = new Widget("123-AB307", "12.7", 109.95);Part A: A Widget is a product. A Widget has an identifier, a productionDate and a Price. The productID of a Widget is the combination of the identifier and productionDate. Product p2 = new Widget("82794-mach10q", "12/7", 89.99);P2 has an identifier of "82794-mach10q" and productionDate of "12/7". Therefore it's productID is: "82794-mach10q_12/7".The Write the constructor for the Widget class. Part B: The canReplace() method determines if one product can be replaced by another. A Product can only be replaced when the identifier of the parameter productID is greater than the identifier of the calling object and when the price of the parameter product is greater than the price of the calling object. Thus p1.canReplace(p2) is false because the price of p2 is less than the price of p1.And p2.canReplace(w1) is false because the productID for w1 comes before the productID of p2.But w1.canReplace(p1) is true because the productID for p1 comes after the productID for w1 and the price w1 is less than the price of p1.Write the canReplace() method for the Product class below.

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 23:30
Step 1: choose your topics review the project milestone reflections you submitted for modules 1 through 4. choose the one major idea or concept from each module that you feel most applies to your life. in addition, choose an important concept from module 5 that applies to your life. step 2: write your guidebook for each module: write a catchy headline that clearly and concisely sums up your chosen idea or concept write a brief explanation that includes a description of the concept, why it is important, and how it can be applied to your life to make a positive impact choose an exciting, powerful, or engaging image that illustrates your concept remember, you are writing one for each module, so you will have a total of five headlines, five descriptions, and five images. step 3: design your guidebook choose a format to present your digital guidebook. there are many 21st century tools available for creating and submitting your work in the online environment. for more information on tools your school uses, contact your instructor or visit the web 2.0 tools area.
Answers: 3
question
Computers and Technology, 22.06.2019 01:40
Kali, a python programmer, is using the turtle module to write the word “hello.” which code should she use to indicate the location to begin writing the word? a # pick up the turtle and move it to its starting location. b penup(-100, 200) goto() pendown() c penup() goto(-100, 200) pendown() d # pick up the turtle and move it to (-100, 200)
Answers: 2
question
Computers and Technology, 22.06.2019 09:00
Howard is designing a chair swing ride. the swing ropes are 5 meters long, and in full swing they tilt in an angle of 29° outside chairs to be 2.75 m above the ground in full swing.
Answers: 1
question
Computers and Technology, 23.06.2019 01:50
Free points just awnser this. what should i watch on netflix
Answers: 2
You know the right answer?
The Product class has a productID and a price. It also has a method getProductID() as shown in the c...
Questions
question
Chemistry, 30.09.2019 19:30
question
Mathematics, 30.09.2019 19:30
question
History, 30.09.2019 19:30
Questions on the website: 13722363