Advertisement
Sajib_Ahmed

Untitled

Apr 13th, 2019
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.94 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 JavaApplication21;
  7.  
  8. import java.util.Scanner;
  9. public class Final {
  10.     public static void main(String[] args)
  11.     {
  12.         Car obj2=new Car(100000);
  13.         Cycle obj1=new Cycle(20.00);
  14.        
  15.         Bob obj=new Bob(obj1,100,5.7,80.00);
  16.         Alice obj3=new Alice(obj2,100,5.6,85);
  17.        
  18.     }
  19.    
  20. }
  21. /*
  22.  * To change this license header, choose License Headers in Project Properties.
  23.  * To change this template file, choose Tools | Templates
  24.  * and open the template in the editor.
  25.  */
  26. package JavaApplication21;
  27.  
  28. /**
  29.  *
  30.  * @author sajib
  31.  */
  32. public class Bob extends Human {
  33.     public Cycle R;
  34.     public double speed;
  35.  
  36.     public Bob(Cycle R, double speed, double h, double w){
  37.         super(h, w);
  38.         this.R = R;
  39.         this.speed = speed;
  40.         System.out.println("Bob Height:"+super.height+"\nBob weight:"+super.weight+"\nCycle Speed:"+speed+"\nCycle Price:"+R.price+"");
  41.         R.Start();
  42.         R.Stop();
  43.     }
  44.    
  45.    
  46. }
  47.  
  48. package JavaApplication21;
  49.  
  50. /**
  51.  *
  52.  * @author sajib
  53.  */
  54. public class Alice extends Human {
  55.     public Car t;
  56.     public double Speed;
  57.  
  58.     public Alice(Car t, double Speed,double h ,double w){
  59.         super(h,w);
  60.         this.t = t;
  61.         this.Speed = Speed;
  62.         System.out.println("Alice Height:"+super.height+"\nAlice weight:"+super.weight+"\nCar Speed:"+Speed+"\nCar Price:"+t.price+"");
  63.         t.Stop();
  64.         t.Stop();
  65.     }
  66.    
  67.    
  68.    
  69.    
  70. }
  71.  
  72. package JavaApplication21;
  73.  
  74. /**
  75.  *
  76.  * @author sajib
  77.  */
  78. public interface Drive {
  79.    
  80.     public void Start();
  81.     public void Stop();
  82.    
  83. }
  84.  
  85. package JavaApplication21;
  86.  
  87.  
  88. public class Cycle extends Vehicle implements Drive{
  89.    
  90.     public Cycle(double price) {
  91.         super(price);
  92.     }
  93.  
  94.    
  95.     public void Start() {
  96.         System.out.println(" start cycle");
  97.     }
  98.  
  99.    
  100.     public void Stop() {
  101.         System.out.println(" stop cycle");
  102.     }
  103.    
  104.    
  105.    
  106.    
  107. }
  108.  
  109. package JavaApplication21;
  110.  
  111.  
  112. public class Car extends Vehicle implements Drive{
  113.  
  114.     public Car(double price) {
  115.         super(price);
  116.     }
  117.  
  118.    
  119.     public void Start() {
  120.         System.out.println("Start car"); //To change body of generated methods, choose Tools | Templates.
  121.     }
  122.  
  123.    
  124.     public void Stop() {
  125.         System.out.println("Stop car"); //To change body of generated methods, choose Tools | Templates.
  126.     }
  127.  
  128.    
  129.    
  130. }
  131.  
  132. package JavaApplication21;
  133.  
  134.  
  135. public class Vehicle {
  136.    
  137.     double price;
  138.  
  139.     public Vehicle(double price) {
  140.         this.price = price;
  141.     }
  142.    
  143.    
  144. }
  145. package JavaApplication21;
  146.  
  147.  
  148.  
  149. public class Human {
  150.     double height;
  151.     double weight;
  152.     public Human(double h, double w)
  153.     {
  154.         height=h;
  155.         weight= w;
  156.     }
  157.    
  158. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement