Assignment need help !

Exercise – Item Class:
Create a class Item with the following private attributes:
 Item ID: should be an integer attribute.
 Item Name: should be a character array attribute of size 20.
 Item Cost: should be a floating-point attribute.
 Item Price: should be a floating-point attribute.
The class Item should contain the following behaviors:
 A constructor with three arguments (ID, Name, and Cost) should initialize the attributes to the parameters passed by calling the set all function.
 A destructor should print the Item Name attribute plus the phrase “has been removed.”
 A set all function that calls the attributes’ set functions.
 Set functions for each attribute except for Item Price.
 Get functions for each attribute.
 A print function to display the values of the object’s attributes.
 A utility function that calculates the Item Price attribute based on the Item Cost value. If the cost was less than 1000, then the price is equal to the cost plus 10%, else the price is equal to the cost plus 20%. This function must be called when the cost is changed.
A header file and source file must be created for class Item.
Another source file must be created for the main function:
 Allow the user to input information (ID, Name and Cost) for two Item objects and pass them to the constructor.
 Create a reference object for the 1st object and a pointer object to the 2nd object.
 Call the print function through the reference and pointer objects.
 Print on the screen the sentence “Destroying two objects:”.
Remark: When the user input the item name, cin.ignore() and cin.getline(name, length) functions must be used to receive the input correctly.

Output should be like this : http://prntscr.com/21tp8u

i need this for today i hope anyone can give me a breif solution or if someone has the abilities to do it thanks a lot
Last edited on
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#ifndef ITEM_H
#define ITEM_H
class Item
{
    private:
       int ItemID;
       char ItemName[20];
       float ItemCost;
       float ItemPrice;

    public:
        Item(int,char[],float);//Constructor
        //Set Functions
        void setItemID(int);
        void setItemName(char);
        void setItemCost(float);
        //Get Functions
        int getItemID();
        int getItemName();
        int getItemCost();
        int getItemPrice();
        void PrintPrice();
        ~getitem(char,"has been removed")
}
#endif 


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include "Item.h"
#include <iosteam>
#include <iomanip>
using namespace std;

//Constructor
Item::Item(int ii,char im,float ic,float ip)
{
	ItemID = ii;
	ItemName = ic[];
	ItemCost = ic;
}

void Item::setItemID(int n)
{
	ItemID = n;
}

void Item::setItemName(char name[])
{
	ItemName = name[];
}

void Item::setItemCost(float c)
{
	ItemCost = c;
}
//Get Functions
int Item::getItemID()
{
	return ItemID;
}
char Item::getItemName()
{
	return ItemName;
}
float Item::getItemCost()
{
	return ItemCost;
}
float Item::getItemPrice()
{
	return ItemPrice;
}

//Print Functions
void Item::PrintPrice()
{
	cout<<"Item ID:"<<ItemId<<endl;
	cout<<"Item Name:"<<ItemName<<endl;
	cout<<"Item cost:"<<ItemCost<<emdl;
}

void Item::Utility()
{
	if(Itemcost<1000)
		ItemPrice = ItemCost + (ItemCost*10)/100
	else 
		ItemPrice = ItemCost + (ItemCost*20)/100
}


1
2
3
4
5
6
7
8
9
10
11
#include "Item.h"
#inlude <iostream>
using namespace std;

void main()
{
	cout <<"Unkown"
	cin>>ItemID
	cout <<"Unkown";
	cin.getline(ItemName, 20)
}


Please i need some help if anyone can reach me throught Skype :jp.waked
Last edited on
Topic archived. No new replies allowed.