Posts

Showing posts from May, 2023

Interface Segregation

  jjjj interface Vehicle { void dive () ; void fly () ; } class Car implements Vehicle { @Override public void dive () {System. out .println( "InterfaceSegregation.Car dive" ) ; } @Override public void fly () { //This not needed to a bike } } Fixing That issue.. interface DrivingVehicle { void dive () ; } interface FlyingVehicle { void fly () ; } class Car implements DrivingVehicle { @Override public void dive () {System. out .println( "InterfaceSegregation.Car dive" ) ; } } class Plane implements DrivingVehicle , FlyingVehicle { @Override public void dive () {System. out .println( "InterfaceSegregation.Plane dive" ) ; } @Override public void fly () {System. out .println( "InterfaceSegregation.Plane fly" ) ; } } class PetrolEngine{} class Vehicle{ private PetrolEngine engine ; Vehicle (PetrolEngine engine){ this . engine =engine ; } } Fixing that issue. interface Engine{} class PetrolEngine implements