Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "pch.h"
- #include <iostream>
- #include "car.cpp"
- #include <windows.h>
- #include "MyList.h"
- int main()
- {
- setlocale(LC_ALL, "Russian");
- BaseCar *MyItem1;
- MyItem1 = new BaseCar("1123", 0, 1, "12");
- return 0;
- }
- #include "pch.h"
- #include <iostream>
- #include <string>
- using namespace std;
- class BaseCar {
- private:
- string Name;
- int Cost;
- double Weight;
- string Manufacturer;
- public:
- BaseCar(string Name, int Cost, int Weight, string Manufacturer) {
- this->Name = Name;
- this->Manufacturer = Manufacturer;
- setCost(Cost);
- setWeight(Weight);
- }
- string getName() {
- return Name;
- }
- void setName(string Name) {
- this->Name = Name;
- }
- int getCost() {
- return Cost;
- }
- void setCost(int Cost) {
- if(Cost < 0) this->Cost = Cost;
- else cout << "Цена для " << Name << " не должна быть меньше 0\n";
- }
- double getWeight() {
- return Weight;
- }
- void setWeight(double Weight) {
- if (Weight < 0) this->Weight = Weight;
- else cout << "Вес для " << Name << " не должна быть меньше 0\n";
- }
- string getManufacturer() {
- return Manufacturer;
- }
- void setManufacturer(string Manufacturer) {
- this->Manufacturer = Manufacturer;
- }
- };
- class TypeCar : public BaseCar {
- private:
- string Type;
- public:
- using BaseCar::BaseCar;
- void setType(string Type) {
- if (Type == "Гражданский" || Type == "Военный")
- this->Type = Type;
- else
- cout << "Машины могут быть \"Гражданский\" или \"Военный\" " << endl;
- }
- string getType() {
- return Type;
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement