Define a class called token number that incorporates a token’s number (could be the last 3 digits of your arid number) and its location. Number each token object as it is created. Use two variables of the angle class to represent the token’s latitude and longitude. A member function of the token class should get a position from the user and store it in the object; another should report the serial number and position. Design a main() program that creates three token, asks the user to input the position of each, and then displays each token’s number and position.
#include<bits/stdc++.h>
using namespace std;
class angle // the angle class will store the location of the token
{
public:
double latitude;
double longitude;
};
class token_number
{
private: // the token_number class consists of two private member variables t_number, position
int t_number;
angle position;
public:
token_number(){}
token_number(int x)
{t_number = x;}
void set_position(angle p) // sets the position if the token
{
position = p;
}
void display_token_information() //displays all the token information
{
cout<<"-------------------------\n";
cout<<"token number is : "<<t_number<<"\n";
cout<<"Location of the token is given as:\n";
cout<<"Latitude : "<<position.latitude<<"\n";
cout<<"Latitude : "<<position.longitude<<"\n";
}
};
int main()
{
vector<token_number*> vec;
cout<<"provide the information of 3 tokens\n";
for(int i=0;i<3;i++)
{
cout<<"ENTER INFORMATION OF TOKEN "<<i+1<<"\n";
int x;
cout<<"provide the token number\n";
cin>>x;
token_number *t=new token_number(x);
cout<<"provide the postion (latitude and longitude) of the token\n";
double longitude,latitude;
cin>>latitude>>longitude;
angle a;
a.latitude = latitude;
a.longitude = longitude;
t->set_position(a);
vec.push_back(t);
}
for(int i=0;i<3;i++)
{
vec[i]->display_token_information();
}
}
Comments
Leave a comment