Hi, can't pass below requirements:
The printlnDesire method in the CheapCar class should display "I want to drive a cheap car".
The printlnDesire method in the LuxuryCar class should display "I want to drive a luxury car".
However in console I see result accordingly to main method method's calls:
I want to drive a luxury car
I want to drive a cheap car
I want to drive a Ferrari
I want to drive a Geo Metro
Can somebody hint me what I'm missing here?
package com.codegym.task.task15.task1503;
/*
OOP: Cars
*/
public class Solution {
public static void main(String[] args) {
new Solution.LuxuryCar().printlnDesire();
new Solution.CheapCar().printlnDesire();
new Solution.Ferrari().printlnDesire();
new Solution.GeoMetro().printlnDesire();
}
public static class Ferrari extends LuxuryCar {
void printlnDesire() {
System.out.println(Constants.WANT_STRING + Constants.FERRARI_NAME);
}
}
protected static class GeoMetro extends CheapCar {
void printlnDesire() {
System.out.println(Constants.WANT_STRING + Constants.GEO_METRO_NAME);
}
}
public static class Constants {
static String WANT_STRING = "I want to drive ";
static String LUXURY_CAR = "a luxury car";
static String CHEAP_CAR = "a cheap car";
static String FERRARI_NAME = "a Ferrari";
static String GEO_METRO_NAME = "a Geo Metro";
}
private static class LuxuryCar {
private void printlnDesire() {
System.out.println(Constants.WANT_STRING + Constants.LUXURY_CAR);
}
}
private static class CheapCar {
private void printlnDesire() {
System.out.println(Constants.WANT_STRING + Constants.CHEAP_CAR);
}
}
}