Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

- ID(int): must be greater than zero. - Price(double): must be greater than zero

ID: 3618279 • Letter: #

Question

-          ID(int): must be greater than zero.

-          Price(double): must be greater than zero.

-         Available (int): how many items available of this product.

-          Trade(String): trademark.

Provide the setters and getters for the variables and atoString() method.

Write a class TV that inherits class Product with the followingdata members:

-         Resolution (double[]): the resolution of the TV.

-          Size(int): the size of the screen.

Provide setters and getters for these variables. Implement themethod powerConsumption() so that it returns (size * resolution[0]* resolution[1]). Override the toString() method so that it returnsa string that showing all the class information. Make sure to usethe toString of the super class.

Write another class “Driver” that contains the main,it should 3 objects of class TV. The output should look likethis:

ID    Price     Available             Trade   Resolution         Size        PowerConsumption

1     500        1000                      Sony     500*700              42          42*500*700

2     xxx        xxx                        xxx        xxx                        xx                          xxx        

3     xxx        xxx                        xxx        xxx                        xx                          xxx

Explanation / Answer

public class Product {     private int id;     private double price;     private String trade;     private int available;     public Product(int id, double price, Stringtrade, int available) {         this.id = id;         this.price = price;         this.trade = trade;         this.available =available;     }     public int getAvailable() {         return available;     }     public void setAvailable(int available) {         this.available =available;     }     public int getId() {         return id;     }     public void setId(int id) {         this.id = id;     }     public double getPrice() {         return price;     }     public void setPrice(double price) {         this.price = price;     }     public String getTrade() {         return trade;     }     public void setTrade(String trade) {         this.trade = trade;     }     @Override     public String toString() {         return("ID        : " + this.getId() +" " +                "Price     : " + this.getPrice() + " $ "+ " "+                "Available : " + this.getAvailable() + " " +                "Trade     : " + this.getTrade());     } }