Question

In: Computer Science

You are tasked to design an application to keep track of sales for your company. Sales...

You are tasked to design an application to keep track of sales for your company. Sales should be tracked for two types of accounts: supplies and services. Complete the following:

    Create a UML class diagram for the Account inheritance hierarchy. Your subclasses should be Supplies and Services.
    All sales accounts will have an account ID (accountId).
    You will need attributes to keep track of the number of hours (numberOfHours) and rate per hour of services provided (ratePerHour).
    You should also keep track of the number of items sold (numberOfItems) and the price per item for the sold supplies (pricePerItem).
    All classes should have a constructor.
    Add getters and setters to all of your classes.
    Override the method toString in all 3 classes.
    Add a method to calculate the sales in each class [calculateSales()].

Submit your UML diagram in a zip file.

This Submission Node will demonstrate the following:

  •     How to create a class diagram
  •     Understanding of inheritance

Solutions

Expert Solution

class Sales
{
    private int accountId;
   
    public Sales(int accountId)
    {
        this.accountId = accountId;
    }
    public String toString()
    {
        return "Sales : AccountId : "+accountId;
    }
    public void setAccountId(int accountId)
    {
        this.accountId = accountId;
    }
    public int getAccountId()
    {
        return accountId;
    }
}
class Supplies extends Sales
{
private int numberOfHours;
private double ratePerHour;
  
public Supplies(int accountId,int numberOfHours,double ratePerHour)
{
   super(accountId);
   this.numberOfHours = numberOfHours;
   this.ratePerHour = ratePerHour;
}
   
    public String toString()
    {
        return "Supplies : Number of hours : "+numberOfHours +" Rate per hour : "+ratePerHour;
    }
    public double calculateSales()
{
   return numberOfHours * ratePerHour;
}
public void setNumberOfHours(int numberOfHours)
{
   this.numberOfHours = numberOfHours;
}
public int getNumberOfHours()
{
   return numberOfHours;
}
public void setRatePerHour(double ratePerHour)
{
   this.ratePerHour = ratePerHour;
}
public double getRatePerHour()
{
   return ratePerHour;
}
}

class Services extends Sales
{
   
private int numberOfItems;
private double pricePerItem;
  
public Services(int accountId,int numberOfItems,double pricePerItem)
{
   super(accountId);
   this.numberOfItems = numberOfItems;
   this.pricePerItem = pricePerItem;
}
  
public String toString()
{
   return "Services: Number Of Items : "+numberOfItems +" Price per Item : "+pricePerItem;
}
public double calculateSales()
{
   return numberOfItems * pricePerItem;
}public void setNumberOfItems(int numberOfItems)
{
   this.numberOfItems = numberOfItems;
}
public int getNumberOfItems()
{
   return numberOfItems;
}
public void setPricePerItem(double pricePerItem)
{
   this.pricePerItem = pricePerItem;
}
public double getPricePerItem()
{
   return pricePerItem;
}
   
}

  
  
class TestSales
{
   public static void main (String[] args)
   {
       Supplies supp = new Supplies(1234,34,4.5);
      
       System.out.println(supp);
      
       Services serv = new Services(4556,6,16.5);
      
       System.out.println(serv);
   }
}

Output:

Supplies : Number of hours : 34 Rate per hour : 4.5
Services: Number Of Items : 6 Price per Item : 16.5

UML

Do ask if any doubt. Please upvote.


Related Solutions

Problem statement: You are tasked with writing a simple program that will keep track of items...
Problem statement: You are tasked with writing a simple program that will keep track of items sold by a retail store. We need to keep track of the stock (or number of specific products available for sale). Requirements: The program will now be broken up into methods and store all the inventory in an ArrayList object. The program will be able to run a report for all inventory details as well as a report for items that are low in...
Problem statement: You are tasked with writing a simple program that will keep track of items...
Problem statement: You are tasked with writing a simple program that will keep track of items sold by a retail store. We need to keep track of the stock (or number of specific products available for sale). Requirements: The Food and Book items should inherit all the properties of the Product item in the previous assignment. Foods cannot be added to the inventory without an expiration date. Implement a toString method for Product, Food, and Book. Grading details: Correct usage...
Using c++ Design a system to keep track of employee data. The system should keep track...
Using c++ Design a system to keep track of employee data. The system should keep track of an employee’s name, ID number and hourly pay rate in a class called Employee. You may also store any additional data you may need, (hint: you need something extra). This data is stored in a file (user selectable) with the id number, hourly pay rate, and the employee’s full name (example): 17 5.25 Daniel Katz 18 6.75 John F. Jones Start your main...
You will design a program to keep track of a restaurants waitlist using a queue implemented...
You will design a program to keep track of a restaurants waitlist using a queue implemented with a linked list. Make sure to read pages 1215-1217 and 1227-1251 1. Create a class named waitList that can store a name and number of guests. Use constructors to automatically initialize the member variables. 2. Add the following operations to your program: a. Return the first person in the queue b. Return the last person in the queue c. Add a person to...
Write a c++ program for the Sales Department to keep track of the monthly sales of...
Write a c++ program for the Sales Department to keep track of the monthly sales of its salespersons. The program shall perform the following tasks: Create a base class “Employees” with a protected variable “phone_no” Create a derived class “Sales” from the base class “Employees” with two public variables “emp_no” and “emp_name” Create a second level of derived class “Salesperson” from the derived class “Sales” with two public variables “location” and “monthly_sales” Create a function “employee_details” under the class “Salesperson”...
Design a database through the EER diagram to keep track of the teams and games of...
Design a database through the EER diagram to keep track of the teams and games of a sport league. Assume that the following requirements are collected (the English description of cardinal ration and partial/complete participate is NOT required, but you still need to provide the total/partial and cardino ration in your EER diagram) : The database has a collection of TEAM. Each Team has a unique name, players, and owner. The database also keeps the records of PLAYERS. Each player...
Design and implement a class called circle_location to keep track of the position of a single...
Design and implement a class called circle_location to keep track of the position of a single point that travels around a circle. An object of this class records the position of the point as an angle, measured in a clockwise direction from the top of the circle. Include these public member functions: • A default constructor to place the point at the top of the circle. • Another constructor to place the point at a specified position. • A function...
A gas station wants a program to keep track of sales. Your gas station sells diesel...
A gas station wants a program to keep track of sales. Your gas station sells diesel for 107.9 cents per litre and regular gas for 112.9 cents per litre. Have the user enter the type of fuel (1 = Regular gas, 2 = Diesel) and number of litres sold. Print out a total for each sale (remember fuel prices already include the GST). Once you enter a 0 for the type of fuel your program should stop and print out...
In the design of communication links we must always keep track of the power needed to...
In the design of communication links we must always keep track of the power needed to represent the signals, the effects of the noise and the bandwidth needed. In a post answer the following : What do you think should be the comparison of signal power vs. noise power? What do you think will be the most effective method to increase the distance in a communications link? What do you think will be the most effective method to increase the...
This is a simple list table of a company trying to keep track of parts that...
This is a simple list table of a company trying to keep track of parts that they sell and orders that came in purchasing those parts (in other words, not a database but a flat one table file). You will design a database for this company so that they won’t be relying on a simple 1 table list system to keep track of their data. Looking at the table below, produce the 3NF of the data. OrderNum OrderDate PartNum Description...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT