Assuming there is a Class called Product which has two product object called p1 and p2 which have the following fields:
P1--> int productId =123, String name ="iPhoneS8", int unitPrice =1000, String datMfs ="12/18/2017". P2--> int productId =124, String name ="Samsung Galaxy S8", int unitPrice =1200, String datMfs ="05/22/2016".
The first question is
1), Write a java code for the product including getters and setters methods, any three overloaded constructors including default. My solution code is the following.
class Product {
Product() {//default Constractor
}
Product(int price) {//Overloaded Constractor1
}
Product(String name) {//Overloaded Constractor2
}
Product(String name, double pri) {//Overloaded Constractor3
}
Product(int name, double pri) {//Overloaded Constractor4
}
// The following is the product fields
private int productId;
private String name;
private int unitPrice;
private String dateMdft;
//The following is getters and setters
public int getproductId() {
return productId;
}
public void setProductId(int productId) {
this.productId = productId;
}
public String getproductName() {
return name;
}
public void setProductname(String name) {
this.name = name;
}
public int getproductunitPrice() {
return unitPrice;
}
public void setUnitPrice(int unitPrice) {
this.unitPrice = unitPrice;
}
public int getUnitPrice() {
return unitPrice;
}
public void setDateMan(String dateMdft) {
this.dateMdft = dateMdft;
}
public String getDateManftd(String dateMdft) {
return dateMdft;
}
The second Question is
2), Write a method called printOutedDatedProduct(from the above) and iterate through the object and print out the data for only the outdated product to the screen in CSV format. the method should print 124, Samsung Galaxy S8,1200, 5/22/2016.
I am really Struggling to write the method and print out the outdated product so I really appreciate the community if anybody helps me and I am also really open to take any comments as far as the solution to the first question is concerned too. Great Thanks!