Write a program that has multiple classes starting with a product class. Also Computer, software and stereo classes that inherit the product class. Laptop and desktop classes inherit computer and also Home Theater and car stereo that inherit the Stereo class. The program should allow you to enter a new product and saves it to the database. Each product is given a unique ID number based on the number of record in the file. On the details tab you can view each record in the file and see the details of each product and even modify the record.
what I did -
In DTO package,
public interface Product {
public int productId();
public String name();
public int price();
public String type();
public void setName(String name);
public void setPrice(int price);
}
then.. I made computer as abstract class which is extending Product(I), desktop and laptop are extending computer and overriding all the methods of product(I). Likewise, I did for the stereo.
Then, In DAO package
public interface ProductDao {
public boolean addProduct(Product product);
public boolean deleteProduct(int productId);
public boolean updateProduct(int productId);
public void retrieveAll();
}
and then I implemented this methods in ProductDaoImpl class. My program is running fine. But what about my design ? Is it correct ? if not, then please suggest me a better design.
Aucun commentaire:
Enregistrer un commentaire