Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "Bus.hpp"
- #include "String.hpp"
- #include <stdio.h>
- #include <iostream>
- #include <string>
- using namespace std;
- Bus:: Bus (const Bus &Q)
- {
- identifity_number = String (Q.identifity_number);
- surname_ = String (Q.surname_);
- route_number = Q.route_number;
- IO_ = Q.IO_;
- }
- bool Bus:: operator > (const Bus &Q) const
- {
- return route_number > Q.route_number;
- }
- bool operator == (const Bus &Q1, const Bus &Q2)
- {
- return Q1.route_number == Q2.route_number;
- }
- void Bus:: operator ++ ()
- {
- route_number++;
- }
- Bus operator ++ (Bus &Q, int n)
- {
- Bus bus = Q;
- Q.route_number++;
- return bus;
- }
- Bus Bus:: operator = (const Bus &Q)
- {
- route_number = Q.route_number;
- identifity_number = Q.identifity_number;
- IO_ = Q.IO_;
- surname_ = Q.surname_;
- return *this;
- }
- Bus Bus:: operator + ( char *s)
- {
- String str;
- str = surname_ + s;
- surname_ = str;
- return *this;
- }
- Bus operator + (Bus &Q, const char *s)
- {
- String str;
- str = Q.surname_ + s;
- Q.surname_ = str;
- return Q;
- }
- char& Bus:: operator [] (int i)
- {
- return identifity_number [i];
- }
- ostream& operator<< (ostream& out, Bus &Q)
- {
- return out <<"identifity number - "<<Q.identifity_number <<"; route number - "<< Q.route_number <<"; the driver - " << Q.surname_<< ' '<< Q.IO_;
- }
- istream& operator>> (istream& in, Bus & Q)
- {
- int n;
- cout << "enter the number of symbols\n";
- in >> n;
- String a(n);
- cout << "enter identifity number\n";
- in >> a;
- cout << "enter the number of symbols\n";
- in >> n;
- String b(n);
- cout << "enter the surname\n";
- in >> b;
- cout << "enter the number of symbols\n";
- in >> n;
- String s(n);
- cout << "enter the inicialy\n";
- in >> s;
- cout << "enter tne number of rout\n";
- short int c;
- in >> c;
- if (c<0)
- throw "tne number is incorrect\n";
- Q =Bus (a,c,b,s);
- return in;
- }
- int Max ( Bus &Q)
- {
- int max_index = 0;
- unsigned long int t = Q.identifity_number.length();
- for (int i=1; i<=t; i++)
- {
- if (Q[i] > Q[max_index])
- {
- max_index = i;
- }
- }
- return max_index+1;
- }
- void Sort (Bus &Q)
- {
- unsigned long int t = Q.identifity_number.length();
- for (int i=1;i<t;i++)
- {
- char key = Q [i];
- int j=i-1;
- while (j>=0 && Q[j]>key)
- {
- Q[j+1]=Q[j];
- j--;
- }
- Q[j+1]=key;
- }
- cout << "changed identifity number is "<<Q.identifity_number << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement