Define a class called token number that incorporates a tokens 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 tokens 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 tokens number and position.
#include <iostream>
using namespace std;
//define token number class
class TokenNumber {
//define data members
private:
int token_num;
float token_lattitude;
float token_longitude;
//methods
public:
void getData(int tNum, float tLat, float tLon) {
token_num=tNum;
token_lattitude=tLat;
token_longitude=tLon;
}
double getLocation() {
return token_lattitude + token_longitude;
}
};
int main() {
//create three objects of class token number
TokenNumber t1;
TokenNumber t2;
TokenNumber t3;
t1.getData(546, 40.8, 39.2);
t2.getData(349, 37.4, 22.6);
t3.getData(234, 43.8, 56.3);
cout << "position of token 1 : " << t1.getLocation() << endl;
cout << "position of token 2 : " << t2.getLocation() << endl;
cout << "position of token 3 : " << t3.getLocation()<< endl;
return 0;
}
Comments
Leave a comment