
Untitled
By: a guest on
Apr 28th, 2012 | syntax:
Java | size: 1.38 KB | hits: 14 | expires: Never
//// letala.java
public interface Letala {
double hitrostKM();
Letala vecjeLetalo(Boeing a, Airbus b, Lovec c);
}
//// boeing.java
public class Boeing extends PrevoznoSredstvo implements Letala{
String tipLetala;
public Boeing(double h, int s, double d, String tl){
super(h, s, d);
this.tipLetala = tl;
}
@Override
public double hitrostKM() {
return getHitrost()*1.609344;
}
@Override
public Letala vecjeLetalo(Boeing a, Airbus b, Lovec c) {
int prvo = Integer.parseInt(a.tipLetala.replaceAll("[\\D]", ""));
int drugo = Integer.parseInt(b.tipLetala.replaceAll("[\\D]", ""));
int tretje = Integer.parseInt(c.tipLetala.replaceAll("[\\D]", ""));
System.out.print("Najvecje letalo je: ");
if(prvo >= drugo && prvo >= tretje){
System.out.print(a.tipLetala);
return a;
}
else if(prvo >= drugo && prvo < tretje){
System.out.print(c.tipLetala);
return c;
}
else {
System.out.print(b.tipLetala);
return b;
}
}
@Override
public String toString(){
return "\nBoeing: " + tipLetala + "\nDolzina poti: "+getdolzinaPoti()+"\nHitrost: "+getHitrost()+
"\nStevilo potnikov: "+getsteviloPotnikov();
}
}