+ 1

Hi all, i want to compare more than two cars how can i do that?

i used this for two cars Vehicle getfastercarmodel(Vehicle x){ if(this.speed > x.speed) return this; return x; } int getfastercar(Vehicle x){ if(this.speed > x.speed) return this.speed; return x.speed; } System.out.println("the faster car is"+" "+ j.getfastercarmodel(o).getModel ()); System.out.println("the speed of car is"+ " "+j.getfastercar(o));

26th Nov 2016, 1:01 PM
ehsan shahbazi
ehsan shahbazi - avatar
2 Antworten
+ 1
can you explain more, and i want add some other feature such as fuel, ... thank you
26th Nov 2016, 1:18 PM
ehsan shahbazi
ehsan shahbazi - avatar
- 1
var fastestcar=car1; if fastestcar<car2.speed fastestcar=car2 if fastestcar<car3.speed fastestcar=car3 ...
26th Nov 2016, 1:38 PM
tomitheninja
tomitheninja - avatar