Lab 6

Description:

For our Sixth lab, we had to make a program that tells how how different types of vehicles move. For example, when a plane is moving backwards its call taxiing. Also for a plane, you fly it, not drive. A car is what you drive, and a ship is what you navigate with.

Code:

package lab6;

public class MovableMain {
	public static void main(String[] args) {
		Movable[] myMovableObject = new Movable [3];
		myMovableObject[0] = new Plane();
		myMovableObject[1] = new Car();
		myMovableObject[2] = new Ship();
		
	for (Movable a : myMovableObject){
		a.moveForward();
		a.moveBackward();
		a.stop();
		a.moveLeft();
		a.moveRight();
		System.out.println("------------------------------");
	}
	
	}

}
package lab6;

public interface Movable {
	public void moveForward();
	public void moveBackward();
	public void stop();
	public void moveLeft();
	public void moveRight();
}
package lab6;

public class Plane implements Movable{

	@Override
	public void moveForward() {
		System.out.println("Plane flying forward");
	}
	@Override
	public void moveBackward() {
		System.out.println("Plane taxiing backwards");
	}
	@Override
	public void stop() {
		System.out.println("Plane landed");
	}
	@Override
	public void moveLeft() {
		System.out.println("Plane flying left");
	}
	@Override
	public void moveRight() {
		System.out.println("Plane flying right");
	}
}

package lab6;

public class Car implements Movable{
	
	@Override
	public void moveForward(){
		System.out.println("Car drives forward");
	}
	
	@Override
	public void moveBackward(){
		System.out.println("Car drives backward");	
	}
	@Override
	public void stop(){
		System.out.println("Car Parked");
	}
	@Override
	public void moveLeft(){
		System.out.println("Car drives left");	
	}
	@Override
	public void moveRight(){
		System.out.println("Car drives right");
	}
}
package lab6;

public class Ship implements Movable{
	
	@Override
	public void moveForward(){
		System.out.println("Ship navigates forward");
	}
	@Override
	public void moveBackward(){
		System.out.println("Ship navigates backward");
	}
	@Override
	public void stop(){
		System.out.println("Ship docked");
	}
	@Override
	public void moveLeft(){
		System.out.println("Ship navigates left");
	}
	@Override
	public void moveRight(){
		System.out.println("Ship navigates right");
	}
}

Screenshot:

PICTURE OF MY PROGRAM RUNNING HERE