#include <iostream>
#include <string>
using namespace std;
class BookStore {
private:
string title;
int inventory;
int total_sales;
public:
BookStore(string title, int inventory, int total_sales = 0) {
this->title = title;
this->inventory = inventory;
this->total_sales = total_sales;
}
void order_book(int qty, int price) {
if (inventory >= qty) {
inventory -= qty;
total_sales += qty * price;
cout << title << " " << qty << "권 판매 완료"<<endl;
} else {
cout << "재고 부족, 현재 남은 수량: " << inventory <<endl;
}
}
int get_inventory() {
return inventory;
}
int get_total_sales() {
return total_sales;
}
};
int main() {
BookStore book("대황유", 5);
book.order_book(10, 10000);
book.order_book(3, 10000);
cout << "남은 재고: " << book.get_inventory() << "권" << endl;
cout << "총 매출: " << book.get_total_sales() << "원" << endl;
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: