Please help me to figure out what is wrong with my code. I tested it in Eclipse and I got correct output
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 {
public void printlnDesire() {
System.out.println(WANT_STRING + "" + FERRARI_NAME);
}
}
public static class GeoMetro extends CheapCar {
public void printlnDesire() {
System.out.println(WANT_STRING + "" + GEO_METRO_NAME);
}
}
public static class LuxuryCar extends Constants{
public void printlnDesire() {
System.out.println(WANT_STRING + ""+ LUXURY_CAR);
}
}
public static class CheapCar extends Constants {
public void printlnDesire() {
System.out.println(WANT_STRING + ""+ CHEAP_CAR);
}
}
public static class Constants {
public String WANT_STRING = "I want to drive ";
public String LUXURY_CAR = "a luxury car";
public String CHEAP_CAR = "a cheap car";
public String FERRARI_NAME = "a Ferrari";
public String GEO_METRO_NAME = "a Geo Metro";
}
}