Guest User

Untitled

a guest
Dec 19th, 2010
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.06 KB | None | 0 0
  1. #include "Car.h"
  2. #include <iostream>
  3. #include <ctime>
  4. #include <cstdlib>
  5.  
  6.  
  7.  
  8.  
  9. Car::Car( string model, string licence,int velocity)
  10. {
  11.     this->model=model;
  12.     this->licence=licence;
  13.     this->velocity=0;
  14. }
  15.  
  16.  
  17. Car::Car()
  18. {
  19.     this->model="Unknown";
  20.     this->licence="Unknown";
  21. }
  22.  
  23. string Car::getModel()
  24. {
  25.     return this->model;
  26. }
  27.  
  28. string Car::getLicence()
  29. {
  30.     return this->licence;
  31. }
  32.  
  33. int Car::getVelocity()
  34. {
  35.     return this->velocity;
  36. }
  37.  
  38. bool Car::CarInMotion()
  39. {
  40.     if(this->velocity!=0)
  41.         return true;
  42.     else
  43.         return false;
  44. }
  45.  
  46. bool Car::winner(int V)
  47. {
  48.     if(this->velocity>=V)
  49.         return true;
  50.     else
  51.         return false;
  52. }
  53.  
  54. void Car::present()
  55. {
  56.     cout<<this->model<<" "<<this->licence<<" "<<this->velocity<<"km/h."<<endl;
  57. }
  58.  
  59. void Car::acceleration()
  60. {
  61.     this->velocity+=rand()%10+1;   
  62. }
  63.  
  64. void Car::retardation()
  65. {
  66.     this->velocity-=rand()%1+5;
  67. }
  68.  
  69. void Car::setVelocity(int velocity)
  70. {
  71.     this->velocity=velocity;
  72. }
  73.  
  74. void Car::setModel(string model)
  75. {
  76.     this->model=model;
  77. }
  78. void  Car::setLicence(string licence)
  79. {
  80.     this->licence=licence;
  81. }
Advertisement
Add Comment
Please, Sign In to add comment