Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion interface_segregation/bad/src/Bird.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@
* Created by mrk on 4/7/14.
*/
public interface Bird {
public void fly();
public void molt();
}
2 changes: 1 addition & 1 deletion interface_segregation/bad/src/Eagle.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* Created by mrk on 4/7/14.
*/
public class Eagle implements Bird {
public class Eagle implements Bird, FlyBird {
String currentLocation;
int numberOfFeathers;

Expand Down
4 changes: 4 additions & 0 deletions interface_segregation/bad/src/FlyBird.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

public interface FlyBird {
public void fly();
}
6 changes: 1 addition & 5 deletions interface_segregation/bad/src/Penguin.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* Created by mrk on 4/7/14.
*/
public class Penguin implements Bird {
public class Penguin implements Bird, SwimBird {
String currentLocation;
int numberOfFeathers;

Expand All @@ -13,10 +13,6 @@ public void molt() {
this.numberOfFeathers -= 1;
}

public void fly() {
throw new UnsupportedOperationException();
}

public void swim() {
this.currentLocation = "in the water";
}
Expand Down
3 changes: 3 additions & 0 deletions interface_segregation/bad/src/SwimBird.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
public interface Bird {
public void swim();
}
5 changes: 5 additions & 0 deletions liskov_substitution/bad/src/BedroomAdder.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
public class BedroomAdder {
public void addBedroom(PenthouseSuite penthouse){
penthouse.numberOfBedrooms +=1;
}
}
5 changes: 4 additions & 1 deletion liskov_substitution/bad/src/PenthouseSuite.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
/**
* Created by mrk on 4/8/14.
*/
public class PenthouseSuite extends Apartment {
public class PenthouseSuite {
int squareFootage;
int numberOfBedrooms;

public PenthouseSuite() {
this.numberOfBedrooms = 4;
}
Expand Down
5 changes: 4 additions & 1 deletion liskov_substitution/bad/src/Studio.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
/**
* Created by mrk on 4/8/14.
*/
public class Studio extends Apartment {
public class Studio {
int squareFootage;
int numberOfRooms;

public Studio() {
this.numberOfBedrooms = 0;
}
Expand Down