Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.87 KB | None | 0 0
  1. class Car  {
  2.  
  3.  
  4.     private String brand;
  5.     private String modell;
  6.     private int bhp;
  7.     private int acc;
  8.     private int weight;
  9.     private int topspeed;
  10.     private double currentspeed;
  11.    
  12.    
  13.     public Car ( String brand, String modell, int bhp, int weight, int topspeed) {
  14.    
  15.     this.brand = brand;
  16.     this.modell = modell;
  17.     this.bhp = bhp;
  18.     this.acc = acc;
  19.     this.weight = weight;
  20.     this.topspeed = topspeed;
  21.     this.currentspeed = currentspeed;
  22.    
  23.         this.acc = (this.topspeed * this.bhp) / ( this.weight);
  24.        
  25.     }
  26.    
  27.     void increasespeed() {
  28.    
  29.         if(this.currentspeed == 0)
  30.             this.currentspeed += 10;
  31.            
  32.         this.currentspeed += (int)(Math.random()*this.acc);
  33.        
  34.         if(this.currentspeed > this.topspeed)
  35.             this.currentspeed = this.topspeed;
  36.            
  37.            
  38.     }
  39.    
  40.     public String getBrand() {
  41.        
  42.         return this.brand;
  43.     }
  44.    
  45.     int getcurrentspeed() {
  46.         return (int)this.currentspeed;
  47.  
  48.     }  
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement