Hi! I was wondering if someone can help me with my assignment! I have to create
ID: 3774129 • Letter: H
Question
Hi! I was wondering if someone can help me with my assignment! I have to create series of classes (with appropriate methods) to manage a small coffee shop. Classes should cover every business entity that would be necessary for the store, including (but not limited to):
-Inventory
-Sales
- Loyalty Cards and Promotions
-Employees (adding employees to system, hourly wages and over time, schedules, time cards, etc.)
-Finances (revenues, expenses, balance, etc)
All classes should have at least a null constructor and copy constructor. Other constructors would be up to your discretion. Include all necessary accessors and modifiers. Your group will determine the utility functions for each class.
To test your classes, create a Container class with simply a main() method. The Container class will have attributes that are class objects of each of the classes you create. The main() method will create the class objects, perform some normal business for that store, and produce appropriate output, like:
-Changes to inventory
-Daily profit
-Any other output appropriate to your chosen business
I would really appreciate any help!! Thank you so much!!:)
Explanation / Answer
#include<iostream>
using namespace std;
//Class Inventory
class Inventory
{
protected:
//Protected member allowes to access in the derived class
int stockInHand;
string iName;
public:
//default constructor
Inventory()
{
stockInHand = 0;
iName = "";
}
//Copy constructor
Inventory(Inventory &iv)
{
iv.stockInHand = stockInHand;
iv.iName = iName;
}
//sets stock in hand
void setStockInHand(int s)
{
stockInHand = s;
}
//sets item name
void setiName(string n)
{
iName = n;
}
//Returns stock in hand
int getStockInHand()
{
return stockInHand;
}
//Returns Item name
string getiName()
{
return iName;
}
};
//Derived class Sales from Inventory
class Sales : public Inventory
{
int itemSold, itemPur;
double purPrice, salePrice;
public:
//Default constructor
Sales()
{
itemSold = 0;
itemPur = 0;
purPrice = 0.0;
salePrice = 0.0;
}
//Copy constructor
Sales(Sales &ss)
{
ss.itemSold = itemSold;
ss.itemPur = itemPur;
ss.purPrice = purPrice;
ss.salePrice = salePrice;
}
//Sets sales price
void setSalePirce(double p)
{
salePrice = p;
}
//Sets purchase price
void setPurPirce(double p)
{
purPrice = p;
}
//Sets Item sold
void setItemSold(int is)
{
itemSold = is;
stockInHand = stockInHand - is;
}
//Sets Item purchased
void setItemPur(int s)
{
itemPur = s;
stockInHand = stockInHand + s;
}
//Returns item sold
int getItemSold()
{
return itemSold;
}
//Returns item purchased
int getItemPur()
{
return itemPur;
}
//Returns purchased price
double getPurPrice()
{
return purPrice;
}
//Returns sales price
double getSalePrice()
{
return salePrice;
}
};
//Loyalty card class
class LoyaltyCards
{
char cardStatus;
public:
//Default constructor
LoyaltyCards()
{
cardStatus = ' ';
}
//Copy constructor
LoyaltyCards(LoyaltyCards &lc)
{
lc.cardStatus = cardStatus;
}
//Sets card status
void setCardStatus(char ch)
{
cardStatus = ch;
}
//Returns card status
char getCardStatus()
{
return cardStatus;
}
};
//Class employee
class Employee
{
protected:
//Protected members allows to access in the derived class
string empName, empCode;
double salary;
public:
//Default constructor
Employee()
{
empName = "";
empCode = "";
salary = 0.0;
}
//Copy constructor
Employee(Employee &e)
{
e.empName = empName;
e.empCode = empCode;
e.salary = salary;
}
//sets employee name
void setEmpName(string n)
{
empName = n;
}
//sets employee code
void setEmpCode(string c)
{
empCode = c;
}
//sets employee salary
void setSalary(double s)
{
salary = s;
}
//Returns employee name
string getEmpName()
{
return empName;
}
//Returns employee code
string getEmpCode()
{
return empCode;
}
//Returns employee salary
double getSalary()
{
return salary;
}
};
//Derived class finance derived from sales, loyaltycard and employee class
class Finance : public Sales, LoyaltyCards, Employee
{
double amtPur, amtSale, expense;
public:
//Default constructor
Finance()
{
amtPur = 0;
amtSale = 0;
expense = 0;
}
//Copy constructor
Finance(Finance &f)
{
f.amtPur = amtPur ;
f.amtSale = amtSale ;
f.expense = expense ;
}
//Calculates the expence
void Calculation()
{
amtPur = getItemPur() * getPurPrice();
amtSale = getItemSold() * getSalePrice();
expense = amtSale - (amtPur + salary) ;
}
//Displays the information
void Show()
{
cout<<" Item Name: "<<getiName();
cout<<" Stock in Hand: "<<getStockInHand();
cout<<" Item Purchased: "<<getItemPur();
cout<<" Price of each Purchased Item: "<<getPurPrice();
cout<<" Amunt for Purchase: "<<amtPur;
cout<<" Item Sold: "<<getItemSold();
cout<<" Price of each Sold Item: "<<getSalePrice();
cout<<" Amunt for Sales: "<<amtSale;
cout<<" Loyalty Card Status: "<<getCardStatus();
cout<<" Employee Code: "<<getEmpCode();
cout<<" Employee Name: "<<getEmpName();
cout<<" Employee Salary: "<<getSalary();
if(expense > 0)
cout<<" Profit: "<<expense;
else if(expense < 0)
cout<<" Loss: "<<expense;
else
cout<<" No Profit No Loss";
}
//Accepts data
void Accept()
{
string s; int st; double p; char cc;
cout<<" Enter Item Name: ";
cin>>s;
setiName(s);
cout<<" Enter Stock in Hand: ";
cin>>st;
setStockInHand(st);
cout<<" Enter Item Purchased: ";
cin>>st;
setItemPur(st);
cout<<" Enter Purchase Price: ";
cin>>p;
setPurPirce(p);
cout<<" Enter Item Sold: ";
cin>>st;
setItemSold(st);
cout<<" Enter Sales Price: ";
cin>>p;
setSalePirce(p);
cout<<" Enter Loyalty Card Information: (y/n)";
cin>>cc;
setCardStatus(cc);
cout<<" Enter Employee Name: ";
cin>>s;
setEmpName(s);
cout<<" Enter Employee Code: ";
cin>>s;
setEmpCode(s);
cout<<" Enter Employee Salary: ";
cin>>p;
setSalary(p);
}
};
int main()
{
Finance ff;
ff.Accept();
ff.Calculation();
ff.Show();
}
Output:
Enter Item Name: Lux
Enter Stock in Hand: 100
Enter Item Purchased: 10
Enter Purchase Price: 2
Enter Item Sold: 50
Enter Sales Price: 100
Enter Loyalty Card Information: (y/n)y
Enter Employee Name: Mohan
Enter Employee Code: 123
Enter Employee Salary: 1000
Item Name: Lux
Stock in Hand: 60
Item Purchased: 10
Price of each Purchased Item: 2
Amunt for Purchase: 20
Item Sold: 50
Price of each Sold Item: 100
Amunt for Sales: 5000
Loyalty Card Status: y
Employee Code: 123
Employee Name: Mohan
Employee Salary: 1000
Profit: 3980
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.