Question: Modify your implemented classes to include the overridden method, computeSales(), that computes the current sales in each of the following categories: Supplies = office supplies
Modify your implemented classes to include the overridden method, computeSales(), that computes the current sales in each of the following categories: Supplies = office supplies sold dollar amount + books sold dollar amount + apparel sold dollar amount Services = number of hours * rate per hour Paper = number of pounds * price per pound Modify your pseudocode from the Phase 2 Discussion Board to include any improvements that were suggested through the discussion. Update your design document with these improvements. Implement your sales tracker application. Implement your sales tracker application according to your pseudocode. Test your application, and provide screenshots demonstrating that your application runs. Intermediate-level Java programming should be demonstrated in your application: There should be implemented constructors for each class. The toString() method should be overridden to provide readable string representation of each object. Getters and setters need to be implemented to enforce data hiding. Code should be fully commented. Program flow should be logical. Behavior should be encapsulated into methods avoiding all encompassing large main() methods. Projects should be developed in NetBeans and zipped prior to submission. Code should compile and run free of exceptions, indicating that debugging tools were used to eliminate any run time errors Here is my code so far, Please help with improvements.
public interface Accounts { void calculate(); }
Class 1 public class PapersAccount implements Accounts { int unitsSold; double unitPrice; double totalSales; public PapersAccount(int unitsSold, double unitPrice) { super(); this.unitsSold = unitsSold; this.unitPrice = unitPrice; } @Override public void calculate() { totalSales = unitPrice * unitsSold; } @Override public String toString() { return "PapersAccount [unitsSold=" + unitsSold + ", unitPrice=" + unitPrice + ", totalSales=" + totalSales + "]"; } }
Class 2 public class ServicesAccount implements Accounts { int serviceACount; int serviceBCount; double basePrice; double totalPrice; public ServicesAccount(int serviceACount, int serviceBCount, double basePrice) { super(); this.serviceACount = serviceACount; this.serviceBCount = serviceBCount; this.basePrice = basePrice; } @Override public void calculate() { totalPrice = serviceACount*basePrice*1.2 + serviceBCount*basePrice*2; } @Override public String toString() { return "ServicesAccount [serviceACount=" + serviceACount + ", serviceBCount=" + serviceBCount + ", basePrice=" + basePrice + ", totalPrice=" + totalPrice + "]"; } }
Class 3 public class SuppliesAccount implements Accounts { int suppliesDue; double fine; int totalSupplies; double total; public SuppliesAccount(int suppliesDue, double fine, int totalSupplies) { super(); this.suppliesDue = suppliesDue; this.fine = fine; this.totalSupplies = totalSupplies; } @Override public void calculate() { total = totalSupplies - suppliesDue - fine*2; } @Override public String toString() { return "SuppliesAccount [suppliesDue=" + suppliesDue + ", fine=" + fine + ", totalSupplies=" + totalSupplies + ", total=" + total + "]"; } } MainClass public class
MainClass { public static void main(String[] args) { Accounts paper = new PapersAccount(5, 135); Accounts service = new ServicesAccount(14, 3, 89); Accounts supplies = new SuppliesAccount(5, 3, 15); paper.calculate(); service.calculate(); supplies.calculate(); System.out.println(paper.toString()+" "+ service.toString()+" "+ supplies.toString()); } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
