![]() |
|
|
Регистрация Восстановить пароль |
Регистрация | Задать вопрос |
Заплачу за решение |
Новые сообщения |
Сообщения за день |
Расширенный поиск |
Правила |
Всё прочитано |
![]() |
|
Опции темы | Поиск в этой теме |
![]() |
#1 |
Новичок
Джуниор
Регистрация: 01.05.2012
Сообщений: 1
|
![]()
Помоги с блок схемой к коду!
#include <string> #include <list> #include <iostream> #include <conio.h> using namespace std; struct CPoint { int x; int y; }; class CVehicle { public: virtual void move()=0; CPoint GetCoords() {return coord;} int GetPrice() {return price;} void SetPrice(int price) {this->price=price;} int GetVelocity() {return velocity;} void SetVelocity(int velocity) {this->velocity=velocity;} int GetYear() {return prodYear;} void SetYear(int prodYear) {this->prodYear=prodYear;} CVehicle () { this->coord.x=0; this->coord.y=0; this->price=0; this->velocity=0; this->prodYear=0; } CVehicle (CPoint coord, int price, int velocity, int prodYear) { this->coord=coord; this->price=price; this->velocity=velocity; this->prodYear=prodYear; }; void SetCoords(CPoint coord) {this->coord=coord;} protected: CPoint coord; int price; int velocity; int prodYear; }; class CCar: public CVehicle { public: CCar() { }; CCar(CPoint coord, int price, int velocity, int prodYear, int passengers):CVehicle(coord, price, velocity, prodYear) { }; void move() { cout<<"The car moves"<<endl; } }; class CShip: public CVehicle { public: CShip() { this->passengers=0; this->port=""; }; CShip(CPoint coord, int price, int velocity, int prodYear, int passengers,string port):CVehicle(coord, price, velocity, prodYear) { this->passengers=passengers; this->port=port; }; int GetPassengers() {return passengers;} void SetPassengers(int passengers) {this->passengers=passengers;} string GetPort() {return port;} void SetPort(string port) {this->port=port;} void move() { cin>>passengers; cout<<"Ship passengers"<<passengers; cout<<"The ship moves"<<endl; } private: int passengers; string port; }; class CPlane ![]() { private: int passengers; int height; public: CPlane() { this->passengers=0; this->height=0; }; CPlane(CPoint coord, int price, int velocity, int prodYear, int passengers,int height):CVehicle(coord, price, velocity, prodYear) { this->passengers=passengers; this->height=height; }; int GetPassengers() {return passengers;} void SetPassengers(int passengers) {this->passengers=passengers;} int GetHeight() {return height;} void SetHeight(int height) {this->height=height;} void move() { cin>>passengers; cout<<"Plane passengers"<<passengers; cout<<"The plane moves"<<endl; } }; void main() { CVehicle *mashinka=new CCar(); CVehicle *samoletik=new CPlane(); CVehicle *korablik=new CShip(); list<CVehicle*> zhelezki; list<CVehicle*>::iterator it; zhelezki.push_back(mashinka); zhelezki.push_back(samoletik) zhelezki.push_back(korablik); for(it=zhelezki.begin();it!=zhelezk i.end();it++) (*it)->move(); getch(); } |
![]() |
![]() |
![]() |
![]() |
||||
Тема | Автор | Раздел | Ответов | Последнее сообщение |
Простой клас STUDENT | aless23 | C++ Builder | 1 | 20.06.2011 17:46 |
Простенький клас | Chartvit | Общие вопросы C/C++ | 2 | 07.01.2010 20:43 |
Як створити гру на Паскалі | DiNis | Паскаль, Turbo Pascal, PascalABC.NET | 9 | 19.01.2009 13:36 |