Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #pragma warning (disable:4996)
- class Game {
- private:
- char title[65];
- double price;
- bool isAvailable;
- public:
- //default constructor
- Game() = default;
- Game(const char* title, double price, bool isAvailable) {
- char* newTitle = new char[strlen(title) + 1];
- strcpy(this->title, title);
- this->price = price;
- this->isAvailable = isAvailable;
- }
- const char* getTitle() const {
- return title;
- }
- double getPrice() {
- return price;
- }
- bool getAvailability() {
- return isAvailable;
- }
- void setTitle() {
- for (int i = 0; i < strlen(title); i++) {
- this->title[i] = title[i];
- }
- }
- void setPrice() {
- this->price = price;
- }
- void setAvailability() {
- this->isAvailable = isAvailable;
- }
- bool isFree() const {
- return price == 0.0;
- }
- void print() {
- std::cout << "Title: " << title << ", Price: " << price << ", Available: " << isAvailable << std::endl;
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement