Problem Description Implement the following classes according to the class diagr
ID: 664513 • Letter: P
Question
Problem Description Implement the following classes according to the class diagrams. And you do not need to implement set and get functions unless otherwise specified. You are required to define function parameters for the Factory contructor (...) and ProductFactory contructor (...) in order to create objects of them properly. All classes need to implement display method. After you implement all the classes and the methods specified in the class diagram, write a main method to create objects of the classes you defined and print out their contents.Explanation / Answer
FileName: Displayable.java
public interface Displayable {
void display();
}
FileName : FactoryConstants.java
public interface FactoryConstants {
int NUM_PRODUCTS=100;
double DISCOUNT=0.2;
}
FileName : Factory.java
public abstract class Factory implements Displayable, FactoryConstants
{
Product[] products;
String factoryName;
Factory() {
}
void setProduct(int pos,Product product)
{
}
}
FileName : Product.java
public abstract class Product extends Factory implements Displayable{
String productName;
public Product(String productName) {
super();
this.productName = productName;
}
public double getDiscounterdPrice()
{
return 0;
}
}
FileName : Building.java
public class Building implements Displayable{
String buildingName;
double area;
Building(String buildingName, double area)
{
this.buildingName=buildingName;
this.area=area;
}
public double getArea()
{
return area;
}
public void display() {
}
}
FileName : ProductFactory.java
public class ProductFactory extends Factory{
Building[] buildings;
public void display() {
}
void setProduct(int pos,Product product)
{
}
Building findLargestBuilding()
{
double large=buildings[0].getArea();
int index=0;
for(Building build:buildings)
{
if(build.getArea()>large)
{
large=build.getArea();
}
index++;
}
return buildings[index];
}
Product[] findAllProductsMore(double price)
{
return products;
}
}
Filename : Computer.java
public class Computer extends Product{
String model;
double price;
public Computer(String model, double price) {
super(model);
this.model = model;
this.price = price;
}
double getPrice()
{
return price;
}
public void display() {
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.