razvanth21

Lab 7 - ex. 4

Nov 4th, 2017
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.99 KB | None | 0 0
  1. class Avion
  2. {
  3.     private String planeID;
  4.     private int totalEnginePower;
  5.    
  6.     public Avion(String s, int ep)
  7.     {
  8.         planeID = s;
  9.         totalEnginePower = ep;
  10.     }
  11.    
  12.     public void takeOff()
  13.     {
  14.         System.out.println(getPlaneID() + " - Initiating takeoff procedure - Starting engines - Accelerating down the runway - Taking off - Retracting gear - Takeoff complete");
  15.     }
  16.    
  17.     public void land()
  18.     {
  19.         System.out.println(getPlaneID() + " - Initiating landing procedure - Enabling airbrakes - Lowering gear - Contacting runway - Decelerating - Stopping engines - Landing complete");
  20.     }
  21.    
  22.     public void fly()
  23.     {
  24.         System.out.println(getPlaneID() + " - Flying");
  25.     }
  26.    
  27.     public int getTotalEnginePower()
  28.     {
  29.         return totalEnginePower;
  30.     }
  31.    
  32.     public String getPlaneID()
  33.     {
  34.         return planeID;
  35.     }
  36. }
  37.  
  38. class avionCalatori extends Avion
  39. {
  40.     private int maxPassengers;
  41.    
  42.     public avionCalatori(String s, int ep, int mp)
  43.     {
  44.         super(s, ep);
  45.         maxPassengers = mp;
  46.     }
  47.    
  48.     public int getMaxPassengers()
  49.     {
  50.         return maxPassengers;
  51.     }
  52. }
  53.  
  54. class Boeing extends avionCalatori
  55. {
  56.     public Boeing(String s, int ep, int mp)
  57.     {
  58.         super(s, ep, mp);
  59.     }
  60. }
  61.  
  62. class Concorde extends avionCalatori
  63. {
  64.     public Concorde(String s, int ep, int mp)
  65.     {
  66.         super(s, ep, mp);
  67.     }
  68.    
  69.     public void goSuperSonic()
  70.     {
  71.         System.out.println(getPlaneID() + " - Supersonic mode activated");
  72.     }
  73.    
  74.     public void goSubSonic()
  75.     {
  76.         System.out.println(getPlaneID() + " - Supersonic mode deactivated");
  77.     }
  78. }
  79.  
  80. class avionLupta extends Avion
  81. {
  82.     public avionLupta(String s, int ep)
  83.     {
  84.         super(s, ep);
  85.     }
  86.    
  87.     public void launchMissile()
  88.     {
  89.         System.out.println(getPlaneID() + " Initiating missile launch procedure - Acquiring target - Launching missile - Breaking away - Missile launch complete");
  90.     }
  91. }
  92.  
  93. class TomCat extends avionLupta
  94. {
  95.     public TomCat(String s, int ep)
  96.     {
  97.         super(s, ep);
  98.     }
  99.    
  100.     public void refuel()
  101.     {
  102.         System.out.println(getPlaneID() + " - Initiating refueling procedure - Locating refueller - Catching up - Refueling - Refueling complete");
  103.     }
  104. }
  105.  
  106. class Mig extends avionLupta
  107. {
  108.     public Mig(String s, int ep)
  109.     {
  110.         super(s, ep);
  111.     }
  112.    
  113.     public void highSpeedGeometry()
  114.     {
  115.         System.out.println(getPlaneID() + " - High speed geometry selected");
  116.     }
  117.    
  118.     public void normalGeometry()
  119.     {
  120.         System.out.println(getPlaneID() + " - Normal geometry selected");
  121.     }
  122. }
  123.  
  124. class Client
  125. {
  126.     public static void main(String[] args)
  127.     {
  128.         Boeing b1, b2;
  129.         Concorde c1, c2;
  130.         TomCat tc1, tc2;
  131.         Mig m1, m2;
  132.        
  133.         b1 = new Boeing("BO-100", 1000, 750);
  134.         b2 = new Boeing("BO-101", 1500, 1000);
  135.         c1 = new Concorde("CO-200", 900, 500);
  136.         c2 = new Concorde("CO-201", 1000, 700);
  137.         tc1 = new TomCat("TCAT-1000", 1500);
  138.         tc2 = new TomCat("TCAT-1002", 1000);
  139.         m1 = new Mig("MIG-1005", 1250);
  140.         m2 = new Mig("MIG-1010", 1300);
  141.        
  142.         b1.takeOff();
  143.         c1.takeOff();
  144.         tc1.takeOff();
  145.         m2.takeOff();
  146.        
  147.         b1.fly();
  148.         c1.fly();
  149.         tc1.fly();
  150.         m2.fly();
  151.        
  152.         c1.goSuperSonic();
  153.         m1.highSpeedGeometry();
  154.         tc1.refuel();
  155.     }
  156. }
Add Comment
Please, Sign In to add comment