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, 22.06.2019 06:00
In outlook how can cherie look at the details of an event that appears on the month view of her calendar? check all that apply. by switching to the detail view by switching to the week view by switching to the day view by right-clicking on the event by double-clicking on the event by highlighting the event
Answers: 2
question
Computers and Technology, 22.06.2019 11:00
The isometric projection camera technique provides an illusion of perspective by using things like parallax scrolling to create the illusion of 3d in a 2d game
Answers: 3
question
Computers and Technology, 22.06.2019 11:40
Design a pos circuit that displays the letters a through j on a seven-segment indicator. the circuit has four inputs w, x, y, and z which represent the last 4 bits of the uppercase ascii code for the letter to be displayed. thus, if wxyz = 0001 then "a" will be displayed. (any answer with 22 or fewer gates and inverters, not counting any for the inputs, is acceptable)
Answers: 2
question
Computers and Technology, 22.06.2019 16:30
Technician a says that a dry sump system uses no oil storage sump under the engine. technician b says that a wet sump system uses no oil storage sump under the engine. who is correct?
Answers: 3
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
English, 05.05.2021 17:10
question
Biology, 05.05.2021 17:10
question
Mathematics, 05.05.2021 17:10
Questions on the website: 13722367