-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSOAL2.cpp
65 lines (48 loc) · 1.19 KB
/
SOAL2.cpp
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
61
62
63
64
65
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
/**
*
* @author Mus
*/
class barangtoko
{
private:
string deskripsi;
int stok;
double harga;
public:
barangtoko(string d, int u, double p)
{ deskripsi = d; stok = u; harga = p; }
void setdeskripsi(string d)
{ deskripsi = d; }
string getdeskripsi()
{ return deskripsi; }
void setstok(int u)
{ stok = u; }
int getstok()
{ return stok; }
void setharga(double p)
{ harga = p; }
double getharga()
{ return harga; }
};
void displayItem(barangtoko);
int main()
{
barangtoko item1("Jacket", 12, 59.95);
barangtoko item2("Designer Jeans", 40, 34.95);
barangtoko item3("Shirt", 20, 24.95);
displayItem(item1);
displayItem(item2);
displayItem(item3);
return 0;
}
void displayItem(barangtoko item)
{
cout << setprecision(2) << fixed << showpoint;
cout << "Deskripsi: " << item.getdeskripsi() << endl;
cout << "Stok: " << item.getstok() << endl;
cout << "Harga: " << item.getharga() << endl << endl;
}