Указание координат двух судов и вывод их на дисплей.

//------------------------------------------------------------------------------------------------
#include <iostream>
#include <conio.h>

using namespace std;
//---------------------------------------------------------
class angle
{
private:
int gradus;
float min;
char ch;
public:
angle(int gr, float mn, char c): gradus(gr), min(mn), ch(c)
{}
void setcord()
{
cout<<"\nEnter the gradus: "; cin>>gradus;
cout<<"Enter the minute: "; cin>>min;
cout<<"Enter the napravlenie (N, S, E, W): "; cin>>ch;
}
void display()const
{
cout<<gradus<<'\xF8'<<min<<"'"<<ch;
}
};
//----------------------------------------------------------
class ship
{

private:
angle wirota;
angle dolgota;
int number;
static int cost;

public:
ship(): wirota(0, 0.0,'W'), dolgota(0, 0.0, 'N'), number(0)
{
cost++;
number=cost;
}
ship(int g1, float m1, char e1, int g2, float m2, char e2):
wirota(g1, m1, e1), dolgota(g2, m2, e2)
{}
void set()
{
cout<<"\nEnter the W I R O R A: ";
cout<<endl<<"[izmnyatnsya ot 0 do 90 gradusov]\n";
wirota.setcord();
cout<<"\nEnter the D O L G O T A: ";
cout<<endl<<"[izmnyatnsya ot 0 do 180 gradusov]\n";
dolgota.setcord();
}
void cdisplay()
{
cout<<"\n\n------SHIP NUMBER----- \""<<number<<"\" "<<endl;
cout<<"\n\nY O U C O O R D I N A T E:"<<endl<<endl;
cout<<"\nWirota: ";
wirota.display();
cout<<"\nDolgota: ";
dolgota.display();
cout<<endl;
}
};
//-------------------------------------------------------------
int ship:: cost=0;
//-------------------------------------------------------------
int main()
{
ship shi1, shi2;
shi1.set();
shi2.set();
shi1.cdisplay();
shi2.cdisplay();
getch();
return 0;
}

//------------------------------------------------------------------------------------------------

Хакинг | Главная | Программирование

Hosted by uCoz