Computers and Technology

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.

answer
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 23.06.2019 06:00, jack487
How can a user delete a drawing object
Answers: 1
image
Computers and Technology, 23.06.2019 11:50, itaheart101
While preforming before operation pmcs, you notice the front right tire appears slightly under-inflated. what is the proper action?
Answers: 3
image
Computers and Technology, 23.06.2019 12:00, anamatiascamaja
If you embed a word table into powerpoint, what happens when you make edits to the embedded data? a. edits made to embedded data change the data in the source file; however, edits made to the source file will not be reflected in the embedded data. b. edits made to embedded data will change the data in the source file, and edits made to the source file will be reflected in the embedded data. c. edits made to embedded data don't change the data in the source file, nor will edits made to the source file be reflected in the embedded data. d. edits made to embedded data don't change the data in the source file; however, edits made to the source file will be reflected in the embedded data.
Answers: 1
image
Computers and Technology, 23.06.2019 16:00, cravens511peeelg
An english teacher would like to divide 8 boys and 10 girls into groups, each with the same combination of boys and girls and nobody left out. what is the greatest number of groups that can be formed?
Answers: 2
Do you know the correct answer?
The Product class has a productID and a price. It also has a method getProductID() as shown in the c...

Questions in other subjects:

Konu
Mathematics, 19.10.2021 18:00
Konu
Mathematics, 19.10.2021 18:00
Konu
Mathematics, 19.10.2021 18:00