+ 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));
2 Respostas
+ 1
can you explain more, and i want add some other feature such as fuel, ...
thank you
- 1
var fastestcar=car1;
if fastestcar<car2.speed fastestcar=car2
if fastestcar<car3.speed fastestcar=car3
...