Interface- EZ

public class Runner { public static void main(String[] args){ Mustang Coyote = new Mustang(); Charger Rt = new Charger(); Challenger Demon = new Challenger(); Camaro SS = new Camaro(); Coyote.print(); Rt.print(); Demon.print(); SS.print(); } } public interface Cars { public void Maker(); public int NumberOfDoors(); public double EngineSize(); public int Horsepower(); } public class Mustang implements Cars { public void print(){ System.out.println("2011 Mustang GT Interface List"); Maker(); System.out.println("Number of Doors: " + NumberOfDoors() ); System.out.println("Engine Size: "+ EngineSize()+" Liters"); System.out.println("Horsepower: "+Horsepower()); System.out.println(" "); } public void Maker(){ System.out.println("Make: Ford"); } public int NumberOfDoors(){ return 2; } public double EngineSize(){ return 5.0; } public int Horsepower(){ return 435; } } public class Challenger implements Cars { public void Maker(){ System.out.println("Make: Dodge"); } public int NumberOfDoors(){ return 2; } public double EngineSize(){ return 6.2; } public int Horsepower(){ return 840; } public void print(){ System.out.println("2017 Challenger Demon Interface List"); Maker(); System.out.println("Number of Doors: " + NumberOfDoors() ); System.out.println("Engine Size: "+ EngineSize()+" Liters"); System.out.println("Horsepower: "+Horsepower()); System.out.println(" "); } } public class Charger implements Cars { public void Maker(){ System.out.println("Make: Dodge"); } public int NumberOfDoors(){ return 4; } public double EngineSize(){ return 5.7; } public int Horsepower(){ return 370; } public void print(){ System.out.println("2017 Charger R/T Interface List"); Maker(); System.out.println("Number of Doors: " + NumberOfDoors() ); System.out.println("Engine Size: "+ EngineSize()+" Liters"); System.out.println("Horsepower: "+Horsepower()); System.out.println(" "); } } public class Camaro implements Cars { public void Maker(){ System.out.println("Make: Chevrolet"); } public int NumberOfDoors(){ return 2; } public double EngineSize(){ return 6.2; } public int Horsepower(){ return 426; } public void print(){ System.out.println("2011 Camaro SS Interface List"); Maker(); System.out.println("Number of Doors: " + NumberOfDoors() ); System.out.println("Engine Size: "+ EngineSize()+" Liters"); System.out.println("Horsepower: "+Horsepower()); } }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.