Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.97 KB | None | 0 0
  1. //My drunk class
  2. class Drunk
  3. {
  4.   public:
  5.     //constructor
  6.     //PRE: valid, initilized turf is passed
  7.     //POST: creates a drunk, obviously
  8.     Drunk( Home_Turf&, string, float, coord );
  9.    
  10.     friend ostream& operator<<( ostream& lhs, Drunk& rhs );
  11.    
  12.   private:
  13.     string name;
  14.     Home_Turf turf;
  15.     float bac;
  16.     coord location;
  17. };
  18.  
  19. //My constructor
  20. Drunk::Drunk( Home_Turf& a_turf, string a_name, float a_bac, coord a_location )
  21. {
  22.   turf = a_turf;
  23.   name = a_name;
  24.   bac = a_bac;
  25.   location = a_location;
  26.  
  27.   //put us at the starting location (hax)
  28.   turf.world[ location.x ][ location.y ] = BARNEY;
  29. }
  30.  
  31. //My main
  32. int main()
  33. {
  34.   srand( time( NULL ) );  
  35.   Home_Turf world1;
  36.   Home_Turf world2( 5, 7, 4, 3 );
  37.   coord loc1, loc2;
  38.  
  39.   loc1.x = loc1.y = loc2.x = loc2.y = 0;
  40.  
  41.   Drunk driver( world1, "Driver", 0.08f, loc1 );
  42.   Drunk driver2( world2, "Driver2", 0.08f, loc2 );
  43.  
  44.   cout << world1;
  45.   cout << world2;
  46.  
  47.   return 0;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement