Sajib_Ahmed

Untitled

Apr 14th, 2019
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.28 KB | None | 0 0
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package hhhhh;
  7.  
  8. /**
  9.  *
  10.  * @author sajib
  11.  */
  12. public abstract class SpaceCraft {
  13.  
  14.     protected String model;
  15.  
  16.     public SpaceCraft(String model) {
  17.         this.model = model;
  18.     }
  19.     public abstract void display();
  20.    
  21. }
  22. /*
  23.  * To change this license header, choose License Headers in Project Properties.
  24.  * To change this template file, choose Tools | Templates
  25.  * and open the template in the editor.
  26.  */
  27. package hhhhh;
  28.  
  29. /**
  30.  *
  31.  * @author sajib
  32.  */
  33. public interface Drive {
  34.     public void drive();
  35.     public void stop();
  36.     public void turn();
  37.    
  38.    
  39. }
  40. /*
  41.  * To change this license header, choose License Headers in Project Properties.
  42.  * To change this template file, choose Tools | Templates
  43.  * and open the template in the editor.
  44.  */
  45. package hhhhh;
  46.  
  47. /**
  48.  *
  49.  * @author sajib
  50.  */
  51. public interface Shuttle {
  52.     public void startShuttle();
  53.     public void stopShuttle();
  54. }
  55. /*
  56.  * To change this license header, choose License Headers in Project Properties.
  57.  * To change this template file, choose Tools | Templates
  58.  * and open the template in the editor.
  59.  */
  60. package hhhhh;
  61.  
  62. /**
  63.  *
  64.  * @author sajib
  65.  */
  66. public class Apollo extends SpaceCraft implements Drive,Shuttle {
  67.    
  68.     private int nowheel;
  69.  
  70.  
  71.     public Apollo(int nowheel, String model) {
  72.         super(model);
  73.         this.nowheel = nowheel;
  74.     }
  75.  
  76.  
  77.     public void display() {
  78.         System.out.println(model+"\n"+nowheel);
  79.     }
  80.  
  81.    
  82.     public void drive() {
  83.         System.out.println("drive");
  84.     }
  85.  
  86.  
  87.     public void stop() {
  88.         System.out.println("stop");
  89.     }
  90.  
  91.    
  92.     public void turn() {
  93.         System.out.println("turn");
  94.     }
  95.  
  96.    
  97.     public void startShuttle() {
  98.         System.out.println("startShuttle");
  99.     }
  100.  
  101.  
  102.     public void stopShuttle() {
  103.         System.out.println("stopShuttle");
  104.     }
  105.     public static void main(String[] args)
  106.     {
  107.         Apollo obj=new Apollo(8,"v974");
  108.         obj.display();
  109.         obj.drive();
  110.         obj.stop();
  111.         obj.turn();
  112.         obj.startShuttle();
  113.         obj.stopShuttle();
  114.     }
  115. }
Advertisement
Add Comment
Please, Sign In to add comment