daily pastebin goal
42%
SHARE
TWEET

Interface Example :)

JanBarhoum Dec 7th, 2017 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. public interface Vehicle {
  3.  
  4.     public void accelerate();
  5.     public void brake ();
  6.     public void steer();
  7. }
  8. ++++++++++++++++++++++++++++++++++++++++++++++++++++
  9.  
  10. public class HondaAccord implements Vehicle {
  11.  
  12.     @Override
  13.     public void accelerate() {
  14.         // TODO Auto-generated method stub
  15.  System.out.println("In HondaAccord.acclerate()");
  16.     }
  17.  
  18.     @Override
  19.     public void brake() {
  20.         // TODO Auto-generated method stub
  21.  
  22.     }
  23.  
  24.     @Override
  25.     public void steer() {
  26.         // TODO Auto-generated method stub
  27.  
  28.     }
  29.  
  30. }
  31. +++++++++++++++++++++++++++++++++++++++++++++++
  32.  
  33. public class Driver {
  34.  
  35.     public static void main(String[] args) {
  36.         Vehicle myVehicle = new Fordmustang();
  37.         myVehicle.accelerate();
  38.        
  39.        
  40.         Vehicle myVehicle2 = new Fordmustang();
  41.         myVehicle.brake();
  42.     }
  43.  
  44. }
  45. ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  46.  
  47.  
  48. public class Fordmustang implements Vehicle {
  49.  
  50.     @Override
  51.     public void accelerate() {
  52.         // TODO Auto-generated method stub
  53.   System.out.println("Fordmustang.acclerate");
  54.     }
  55.  
  56.     @Override
  57.     public void brake() {
  58.         // TODO Auto-generated method stub
  59. System.out.println("Fordmustang has a  good brakes");
  60.     }
  61.  
  62.     @Override
  63.     public void steer() {
  64.         // TODO Auto-generated method stub
  65.  
  66.     }
  67.  
  68. }
RAW Paste Data
Top