Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted as Java by Gibby ( 7 years ago )
public class SportsCar extends Vehicles {
	// Fields
	int coolFactor;
	boolean isBMW;
	boolean isMercedes;
	int handling;
	// Constructors
	public SportsCar() {
		super();
		int coolFactor = 0;
		boolean isBMW = false;
		boolean isMercedes = false;
		int handling = 0;
	}
	public SportsCar(int h, int t, int mileage, String n, int cf, boolean bmw, boolean merc, int hand) {
		super(h,t,mileage,n);
		if ((bmw && merc)) {
			System.out.println("We have chosen Mercedes for you, since you wanted both.");
		    isMercedes = true;
			isBMW = false;
		}
		if ((bmw) && !(merc)) {
			System.out.println("Unfortunately, your car is a BMW.");
			isBMW = true;
			isMercedes = false;
		}
		if (!(bmw) && (merc)) {
			System.out.println("Your car is a Mercedes, good choice!");
			isBMW = false;
			isMercedes = true;
		}
		if (!(bmw) && !(merc)) {
			isBMW = false;
			isMercedes = false;
		}
		coolFactor = cf;
		handling = hand;
	}
	public boolean isaBMW() {
		if (isBMW) {
			return true;
		}
		else {
			return false;
		}
	}
	@Override
	public void drive() {
		if ((this.getHorsepower() > 400 )&& (handling > 10)) {
			System.out.println("You go for a drive, and have some fun.");
			return;
		}
		if ((this.getHorsepower() > 400 )&& (handling < 10)) {
			System.out.println("You go for a drive, and die.");
			return;
		}
		System.out.println("You go for a ride, it's kinda boring.");
	}
}

 

Revise this Paste

Your Name: Code Language: