Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Car {
- private String brand;
- private String modell;
- private int bhp;
- private int acc;
- private int weight;
- private int topspeed;
- private double currentspeed;
- public Car ( String brand, String modell, int bhp, int weight, int topspeed) {
- this.brand = brand;
- this.modell = modell;
- this.bhp = bhp;
- this.acc = acc;
- this.weight = weight;
- this.topspeed = topspeed;
- this.currentspeed = currentspeed;
- this.acc = (this.topspeed * this.bhp) / ( this.weight);
- }
- void increasespeed() {
- if(this.currentspeed == 0)
- this.currentspeed += 10;
- this.currentspeed += (int)(Math.random()*this.acc);
- if(this.currentspeed > this.topspeed)
- this.currentspeed = this.topspeed;
- }
- public String getBrand() {
- return this.brand;
- }
- int getcurrentspeed() {
- return (int)this.currentspeed;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement