Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 28th, 2012  |  syntax: Java  |  size: 1.38 KB  |  hits: 14  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. //// letala.java
  2. public interface Letala {
  3.     double hitrostKM();
  4.     Letala vecjeLetalo(Boeing a, Airbus b, Lovec c);
  5. }
  6.  
  7.  
  8.  
  9.  
  10. //// boeing.java
  11. public class Boeing extends PrevoznoSredstvo implements Letala{
  12.    
  13.  
  14.     String tipLetala;
  15.    
  16.     public Boeing(double h, int s, double d, String tl){
  17.         super(h, s, d);
  18.         this.tipLetala = tl;
  19.     }
  20.  
  21.     @Override
  22.     public double hitrostKM() {
  23.         return getHitrost()*1.609344;
  24.     }
  25.  
  26.  
  27.     @Override
  28.     public Letala vecjeLetalo(Boeing a, Airbus b, Lovec c) {
  29.         int prvo = Integer.parseInt(a.tipLetala.replaceAll("[\\D]", ""));
  30.         int drugo = Integer.parseInt(b.tipLetala.replaceAll("[\\D]", ""));
  31.         int tretje = Integer.parseInt(c.tipLetala.replaceAll("[\\D]", ""));
  32.         System.out.print("Najvecje letalo je: ");
  33.         if(prvo >= drugo && prvo >= tretje){
  34.             System.out.print(a.tipLetala);
  35.             return a;
  36.         }
  37.         else if(prvo >= drugo && prvo < tretje){
  38.             System.out.print(c.tipLetala);
  39.             return c;
  40.         }
  41.         else {
  42.             System.out.print(b.tipLetala);
  43.             return b;
  44.         }
  45.     }
  46.     @Override
  47.     public String toString(){
  48.         return "\nBoeing: " + tipLetala + "\nDolzina poti: "+getdolzinaPoti()+"\nHitrost: "+getHitrost()+
  49.                 "\nStevilo potnikov: "+getsteviloPotnikov();
  50.     }
  51.    
  52. }