Advertisement
Guest User

Untitled

a guest
Mar 29th, 2020
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.92 KB | None | 0 0
  1. #pragma once
  2. #include <iostream>
  3. #include <cstring>
  4.  
  5. using namespace std;
  6.  
  7. class Product
  8. {
  9. private:
  10.     int SKU;
  11.     char* brand;
  12.     char* model;
  13.     char* category;
  14.     char* color;
  15.     double size, price;
  16.     int count;
  17.  
  18.     void erase()
  19.     {
  20.         delete[] this->brand;
  21.         delete[] this->model;
  22.         delete[] this->category;
  23.         delete[] this->color;
  24.     }
  25.  
  26.     void copy(const Product& other)
  27.     {
  28.         this->brand = new char[strlen(other.brand) + 1];
  29.         this->model = new char[strlen(other.model) + 1];
  30.         this->category = new char[strlen(other.category) + 1];
  31.         this->color = new char[strlen(other.color) + 1];
  32.        
  33.         this->SKU = other.SKU;
  34.         this->size = other.size;
  35.         this->price = other.price;
  36.         this->count = other.count;
  37.  
  38.         strcpy_s(this->brand, strlen(other.brand) + 1, other.brand);
  39.         strcpy_s(this->model, strlen(other.model) + 1, other.model);
  40.         strcpy_s(this->category, strlen(other.category) + 1, other.category);
  41.         strcpy_s(this->color, strlen(other.color) + 1, other.color);
  42.     }
  43. public:
  44.     Product();
  45.     Product(int SKU, const char* brand, const char* model, const char* category, const char* color, double size, double price, int count);
  46.     Product(const Product& other);
  47.     Product& operator =(const Product& other);
  48.  
  49.  
  50.     // Getters
  51.     int getSKU() const;
  52.     const char* getBrand() const;
  53.     const char* getModel() const;
  54.     const char* getCategory() const;
  55.     const char* getColor() const;
  56.     double getSize() const;
  57.     double getPrice() const;
  58.     int getCount() const;
  59.  
  60.     // Setters
  61.     void setSKU(int _SKU);
  62.     void setBrand(const char* _brand);
  63.     void setModel(const char* _model);
  64.     void setCategory(const char* _category);
  65.     void setColor(const char* _color);
  66.     void setSize(double _size);
  67.     void setPrice(double _price);
  68.     void setCount(int _count);
  69. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement