Question
The current code I have is the following: package uml; public class uml { public static void main(String[] args) { // TODO Auto-generated method stub
The current code I have is the following:
package uml;
public class uml {
public static void main(String[] args) {
// TODO Auto-generated method stub
}
}
class Account {
private String accountID;
public Account(String accountID) {
this.accountID = accountID;
}
public String getAccountID() {
return accountID;
}
public void setAccountID(String accountID) {
this.accountID = accountID;
}
@Override
public String toString() {
return "Account [accountID=" + accountID + "]";
}
}
class SuppliesAccount extends Account {
private int numberOfItems;
private double pricePerItem;
public SuppliesAccount(String accountID, int numberOfItems, double pricePerItem) {
super(accountID);
this.numberOfItems = numberOfItems;
this.pricePerItem = pricePerItem;
}
public int getNumberOfItems() {
return numberOfItems;
}
public void setNumberOfItems(int numberOfItems) {
this.numberOfItems = numberOfItems;
}
public double getPricePerItem() {
return pricePerItem;
}
public void setPricePerItem(double pricePerItem) {
this.pricePerItem = pricePerItem;
}
@Override
public String toString() {
return "SuppliesAccount [numberOfItems=" + numberOfItems + ", pricePerItem=" + pricePerItem + "]";
}
}
class ServiceAccount extends Account {
private int numberOfHours;
private double ratePerHour;
public ServiceAccount(String accountID, int numberOfHours, double ratePerHour) {
super(accountID);
this.numberOfHours = numberOfHours;
this.ratePerHour = ratePerHour;
}
public int getNumberOfHours() {
return numberOfHours;
}
public void setNumberOfHours(int numberOfHours) {
this.numberOfHours = numberOfHours;
}
public double getRatePerHour() {
return ratePerHour;
}
public void setRatePerHour(double ratePerHour) {
this.ratePerHour = ratePerHour;
}
@Override
public String toString() {
return "ServiceAccount [numberOfHours=" + numberOfHours + ", ratePerHour=" + ratePerHour + "]";
}
}
I am tasked with the folllowing:
In Eclipse, implement your account class diagram created earlier. Complete the following:
Your Java project should include 3 classes: Account.java, Services.java, and Supplies.java. There should be implemented constructors for each class. The toString() method should be overridden to provide a readable string representation of each object. Getters and setters need to be implemented to enforce data hiding. The calculateSales() method should be implemented for all classes Consider having the calculateSales() as an abstract method for the Abstract Account class. In addition, you need to create a test class companySales.java that tests each subclass's constructor, toString(), and computeSales(). You need to create an instance of each subclass. Input can be hard-coded or entered by the user. You need to call the method calculateSales() for each instance. You need to print each class info using its method toString(). Code should be fully commented. Program flow should be logical.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started