Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package JavaApplication21;
- import java.util.Scanner;
- public class Final {
- public static void main(String[] args)
- {
- Car obj2=new Car(100000);
- Cycle obj1=new Cycle(20.00);
- Bob obj=new Bob(obj1,100,5.7,80.00);
- Alice obj3=new Alice(obj2,100,5.6,85);
- }
- }
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package JavaApplication21;
- /**
- *
- * @author sajib
- */
- public class Bob extends Human {
- public Cycle R;
- public double speed;
- public Bob(Cycle R, double speed, double h, double w){
- super(h, w);
- this.R = R;
- this.speed = speed;
- System.out.println("Bob Height:"+super.height+"\nBob weight:"+super.weight+"\nCycle Speed:"+speed+"\nCycle Price:"+R.price+"");
- R.Start();
- R.Stop();
- }
- }
- package JavaApplication21;
- /**
- *
- * @author sajib
- */
- public class Alice extends Human {
- public Car t;
- public double Speed;
- public Alice(Car t, double Speed,double h ,double w){
- super(h,w);
- this.t = t;
- this.Speed = Speed;
- System.out.println("Alice Height:"+super.height+"\nAlice weight:"+super.weight+"\nCar Speed:"+Speed+"\nCar Price:"+t.price+"");
- t.Stop();
- t.Stop();
- }
- }
- package JavaApplication21;
- /**
- *
- * @author sajib
- */
- public interface Drive {
- public void Start();
- public void Stop();
- }
- package JavaApplication21;
- public class Cycle extends Vehicle implements Drive{
- public Cycle(double price) {
- super(price);
- }
- public void Start() {
- System.out.println(" start cycle");
- }
- public void Stop() {
- System.out.println(" stop cycle");
- }
- }
- package JavaApplication21;
- public class Car extends Vehicle implements Drive{
- public Car(double price) {
- super(price);
- }
- public void Start() {
- System.out.println("Start car"); //To change body of generated methods, choose Tools | Templates.
- }
- public void Stop() {
- System.out.println("Stop car"); //To change body of generated methods, choose Tools | Templates.
- }
- }
- package JavaApplication21;
- public class Vehicle {
- double price;
- public Vehicle(double price) {
- this.price = price;
- }
- }
- package JavaApplication21;
- public class Human {
- double height;
- double weight;
- public Human(double h, double w)
- {
- height=h;
- weight= w;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement