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 18:00
What ordering of tcp flags makes up the three-way handshake?
Answers: 2
question
Computers and Technology, 21.06.2019 22:20
This problem has been solved! see the answeran evil king has a cellar containing n bottles of expensive wine, and his guards have just caught a spy trying to poison the king’s wine. fortunately, the guards caught the spy after he succeeded in poisoning only one bottle. unfortunately, they don’t know which one. to make matters worse, the poison the spy used was very deadly; just one drop diluted even a billion to one will still kill someone. even so, the poison works slowly; it takes a full month for the person to die. design a scheme that allows the evil king to determine exactly which one of his wine bottles was poisoned in just one month’s time while expending at most o(logn) of his taste testers.you are not allowed to use n testers, one for each bottle, and see which one tester dies after 30 days.(no pseudocode needed. just answer in words, how many testers you use, how you use them and why you correctly identify the poisoned bottle in 30 days)
Answers: 2
question
Computers and Technology, 22.06.2019 23:30
Jaina and tomas are being considered as new tenants in an apartment. the landlord looks at their creditworthiness because he wants to be sure his new tenant pays the rent on time and in full. the table below summarizes the information that was on their applications. application information questions jaina tomas how many years have you had your job? 5 2 what is your monthly salary? $1,850 $2,500 how many credit cards do you have? 4 1 how much debt do you have? $13,000 $7,000 how many times were you late with payments on credit cards in the past year? 5 1 who will the landlord decide to be more creditworthy and why? tomas because the ratio of his debt to income is less. jaina because she has had her job longer, which makes her look more stable. jaina because she has more credit cards available to her. tomas because he makes more money per month.
Answers: 2
question
Computers and Technology, 22.06.2019 23:30
Select all that apply. which of the following are proofreading options included in microsoft word? spell check find replace grammar check formatting check
Answers: 1
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
Mathematics, 05.10.2020 15:01