Write a program that implements an online grocery shopping. The online grocery store contains three main components: Grocery, Inventory, and people who access the program (customers and administration)
Grocery:
The store contains 5 types of groceries: Dairy, Cereal, Bread, Jam, and Soup. They all have some common and specialized properties. The common properties are name, price, quantity on hand, and quantity purchased. Each dairy has a specialized property called temperature, for cereal is the aisle number, for bread is the weight, for jam is its size, and for soup is its type.
Inventory
The main important property of inventory is the list of groceries kept in the store. The main functions include: Adding new grocery, deleting an existing grocery, modifying information of a grocery, and listing (viewing) of all groceries.
Customer:
Each customer is identifies with the following main properties: customer id, name, password, and address. There are also two more properties that keep track of the items purchased by the customer and total billing of the customer when customer starts shopping. Thus, for each customer you need to keep a list of items that he/she is buying and based on the items the customer picks up from the store you need to update his/her billing.
When an existing customer access the system, he/she should be allowed to list his/her purchased items, see what is in the inventory and buy an item, be able to change his/her mind and delete an item from his/her list and at the end of his/her shopping submit a request for delivery.
Administration:
An administrator can modify information on customers and groceries and run transaction files that update the information in the store.
I have written the classes and some of the required members for you in this assignment. I also wrote some comments that help you writing your code in each routine. In this assignment, you are required to make the GroceryItem as an abstract class. I have placed a pure virtual function called PrintGrocery that should simply print the current state of attributes of an object of type GroceryItem in each derived class on the screen.
You can add other routines as you wish; however, you are not allowed to delete or modify any of the properties I have already placed in each class unless you discuss it with me.
class GroceryItem
{
protected:
string itemName;
float temPrice;
int qtyOnHand;
int qtyPurchased;
public:
virtual void PrintGrocery()=0;
};
//-----------------------------
class Dairy: public GroceryItem
{
protected:
float temperature;
public:
virtual void PrintGrocery()
};
//-----------------------------
class Cereal: public GroceryItem
{
protected:
int aisle;
public:
virtual void PrintGrocery()
};
//-----------------------------
class Bread: public GroceryItem
{
protected:
float weight;
public:
virtual void PrintGrocery()
};
//-----------------------------
class Jam: public GroceryItem
{
protected:
string size; // must be one of “small”, “medium”, or “large”
public:
virtual void PrintGrocery()
};
//-----------------------------
class Soup: public GroceryItem
{
protected:
string type; // must be “dry” or “liquid”
public:
virtual void PrintGrocery()
};
//-----------------------------
class Inventory
{
protected:
vectorgitems;
public:
void AddNewGrocery();
void DeleteGrocery();
void ModifyGrocery();
void ListAllItems();
};
//-----------------------------
class Customer
{
protected:
long custID;
string custPass;
string custName;
string custAddress;
float custTotalBill;
vectorgitemsPurchased;
public:
void PrintCustomer();
void ListPurchasedItems();
void BuyAnItem(Inventory&);
void RemovePurchasedItem(Inventory&);
void SubmitRequest();
};
//-----------------------------
class OnlineShopping
{
protected:
vectorcust;
string adminPassword;
Inventory inv;
public:
OnlineShopping(){adminPassword="12345";};
~OnlineShopping(){};
int AddCustomer();
int DeleteCustomer();
int ModifyCustomer();
int setNewAdminPassword(string newPass)
int ListAllCustomers();
int StartUp();
};
void Customer::PrintCustomer()
{ // sampling prints the information (name, id, … etc ) of a customer
}
//-----------------------------
void Customer::ListPurchasedItems()
{
// lists all the groceries (with all their properties) purchased by a customer
}
//-----------------------------
void Customer::BuyAnItem(Inventory& inv)
{
// allow the customer to view the entire inventory in here then
// ask the customer to pick up an item and ask him/her how many wants to buy
// add the selected item to the list of items purchased by the customer
// modify the customer bill
// modify the item in the inventory (quantity purchased, and quantity on hand)
// you should let the customer stay in this routine as long as he/she wishes. You can ask the customer to exit
// by typing zero
}
//-----------------------------
void Customer::RemovePurchasedItem(Inventory& inv)
{
// allow the customer to view the list of item he/she has purchased
// ask the customer to pick up an item he/she wants to delete
// remove the item from the his/her grocery list
// modify the customer bill
// modify the item in the inventory (quantity purchased, and quantity on hand)
// you should let the customer stay in this routine as long as he/she wishes. You can ask the customer to exit
// by typing zero
}
//-----------------------------
void Customer::SubmitRequest()
{
// show the list of items purchased by the customer and show the amount that is due.
// ask the customer if he/she is sure to submit the request. Show the customer his/her address and
// let the customer know that the items will be delivered to that address. Note that if the customer’s address
is changed, the customer may not wish the items to be sent to a wrong place.
// if the answer is yes,
// print appropriate message for the customer letting the customer know that
// someone will deliver the items to his/her house within 24 hours.
// finally, reset the shopping status of the customer by making the customer bill to zero
// and removing the purchased items from his/her list of shopping
}
//-----------------------------
//-----------------------------
//-----------------------------
//-----------------------------
//-----------------------------
void Inventory::AddNewGrocery()
{
//interactively ask the user (administration) what type of grocery should be added: (Diary, Jam, etc..)
//interactively ask for the information of the grocery, name, price, etc.
//insert the new grocery to the list of groceries in the inventory if it is not there already
// you should let the admin to stay in this routine as long as he/she wishes. This way
// admin can add more than one item. You can ask the admin to exit by typing zero
}
//-----------------------------
void Inventory::DeleteGrocery()
{
//show the admin the list of groceries
//admin will select the one that should be deleted
//based on admin selection, remove the item from the inventory
// you should let the admin to stay in this routine as long as he/she wishes. This way admin can delete more
// than one item if necessary
//-----------------------------
void Inventory::ModifyGrocery()
{
//show the admin the list of groceries
//ask admin which item should be modified
//admin selects the item and then you need to ask which field should be modified
//based on the field selection interactively, ask admin for the new information
// you should let the admin to stay in this routine as long as he/she wishes. This way admin can modify more
// than one item if necessary
//-----------------------------
void Inventory::ListAllItems()
{
// this routine should show all groceries on the screen
}
//-----------------------------
void OnlineShopping::changeAdminPassword()
{
// this routine changes admin password. Your constructor sets admin password to “12345” in the constructors
// to start with
}
//-----------------------------
void OnlineShopping::ListAllCustomers()
{
// this routine lists all the customers on the screen
}
//-----------------------------
void OnlineShopping::AddCustomer()
{
// interactively ask admin/customer to enter information of the new customer.
// as long as it is a new user, (different name and password) it can be accepted
}
//-----------------------------
void OnlineShopping::DeleteCustomer()
{
// list the customers for admin to view which one should be deleted
// admin selects the one that should be deleted
// you should let the admin to stay in this routine as long as he/she wishes. This way admin can delete more
// than one item if necessary
}
//-----------------------------
void OnlineShopping::ModifyCustomer()
{
//list the customers for admin to view which one should be modified
//admin selects the one that should be deleted
// ask admin which field should be modified
// you should let the admin to stay in this routine as long as he/she wishes. This way admin can delete more
// than one item if necessary
}
//-----------------------------
void OnlineShopping::StartUp()
{
// your main program should call this routine first
// you ask the user the following questions
1: existing customer " << endl;
2: new customer " << endl;
3: admin " << endl;
4: quit " << endl;
// if it is a new customer, your program interactively ask the information of the customer and as long
// as such a customer does not exist, it should be allowed to be added to the list of customers
// if it is an existing customer, check the name and password for security. If it is a valid
// customer, two actions can be done:
a) change profile
b) do shopping
// if an existing customers wants to change his/her profile, you need to ask for his/her new information
// and modify the customer profile appropriately; otherwise, call the BuyAnItem() routine or this
// customer to start shopping
// if it is the admin, you need to ask for his/her password to see if it matches the admin password. If it is a
// accepted, the admin can do the following task:
1 : change your password
2 : add new customer
3 : delete a customer
4 : modify a customer
5 : add new grocery
6 : remove a grocery
7 : modify a grocery
8 : List groceries
9 : List customers
10 : Process Transaction File
11 : quit
All of the above are all self-explanatory. The last one is Process transaction file. You can create a routine that reads a transaction file and process the commands. There are only three commands: InsertGrocery, InsertCustomer, and AddToQtyOnHand.
InsertGrocery is followed by the type of grocery and its properties. For example an example of inserting a Cereal is:
InsertGrocery Cereal Raisin_Brand 2.40 20 0 3
Which means it is Raisin-brand cereal that costs $2.40 and there are 20 of them exist in the store. No purchase has been done and the cereal is in aisle 3.
InsertCustomer is followed by the properties of the new customer. You need to ensure that such a customer already does not exist in the system. An example of InsertCustomer is:
InsertCustomer 1111 28&&28** Jim_Stairs 899_Adams_street_SanMarcos
Which means it is customer number 1111 with password of 28&&28**. His name is Jim_Stairs. And his address is 899_Adams_street_SanMarcos.
AddToQtyOnHand is followed by item type and item name and a number that indicates how many “the quantity on hand” should be increased. For example
AddToQtyOnHand Cereal Raisin_Brand 20
means the quantity on hand of raisin-brand cereal should be increased by 20.
}
//-----------------------------
int main( )
{
OnlineShopping VONS;
VONS.StartUp();
return 0;
}