Question: IN C++ A company has a large computer store Each item in the store has an ID , Manufacture_Date , Description and Price . The
IN C++
A company has a large computer store Each item in the store has an ID, Manufacture_Date , Description and Price. The store contains a range of items including PCs and printers. Each PC has a CPU_type, Speed, hard_Disk_Size and RAM size. Each printer has a Type (e.g. Laser, Inkjet), Speed (Pages per minute), paper_capacity, and RAM_size. Item ID is generated automatically starting from 1000000. Description, CPU_type, printer type are declared as string. ManufactureDate is of type Date given below, the rest are declared as integers.
* Make sure to do any necessary validations.
* All data members should be defined as private.
class Date {
int day, month, year;
public:
Date (int d = 1, int m =1 , int y=1990) { day = d; month = m; year = y; }
void SetDate(int d, int m , int y) { day = d; month = m; year = y; }
void Display() const { cout << day << "/" << month << "/" << year <
int getYear(){return year; }
};
- Create a base class ITEM with all necessary members and based on the following:
- A initializer constructor
- A set function to set values of Description, Price and Manufacture_Date.
- A function named Display to print attributes defined in ITEM
- A get function that returns the price of the item
- A get function that returns the Manufacture_Date of the item
- A pure virtual function named setValues( string description, Date d, float price) to set the attributes in the base class.
- Create the class PC derived from the base class item, with all necessary members and based on the following:
- An initializer constructor
- A set function named setValues to set values of Description, Price, Manufacture_Date, CPU_type, Speed, hard_Disk_Size and RAM size
- A function named Display to print all attributes
- A function that can give you the total number of PC objects created at any given time
- Create the class PRINTER derived from the base class item, with all necessary members and based on the following:
- An initializer constructor
- A set function named setPC_Printer to set values of Description, Price, Manufacture_Date, Type, Speed, paper_capacity, and RAM_size
- A function named Display to print all attributes
- A function that can give you the total number of PRINTER objects created at any given time
Write a program to test the classes you have created in sections above.
- Declare an array of pointers name it STORE of type ITEM of size 100
- For each pointer in the array, allow the user to enter the choice of the item to be allocated by each pointer in the STORE array, the user should enter the details of attributes for the object to be created.
- Print the number of PCs in the store.
- Print the details of all printers with manufacture year 2016
- Display the details of all objects in the array that have a price higher than 300 JD.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
