Skip to content

Commit

Permalink
Merge pull request matyb#65 from harryxp/correct-cast-method-names
Browse files Browse the repository at this point in the history
Correct downcast and upcast method names.
  • Loading branch information
matyb authored Jul 9, 2016
2 parents 2761cae + 3bace63 commit 88d47c9
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions koans/src/beginner/AboutCasting.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public String complain() {
}

@Koan
public void downCastWithInheritance() {
public void upcastWithInheritance() {
Child child = new Child();
Parent parentReference = child; // Why isn't there an explicit cast?
assertEquals(child instanceof Child, __);
Expand All @@ -68,15 +68,15 @@ public void downCastWithInheritance() {
}

@Koan
public void downCastAndPolymorphism() {
public void upcastAndPolymorphism() {
Child child = new Child();
Parent parentReference = child;
// If the result is unexpected, consider the difference between an instance and its reference
assertEquals(parentReference.complain(), __);
}

@Koan
public void upCastWithInheritance() {
public void downcastWithInheritance() {
Grandparent child = new Child();
Parent parentReference = (Parent) child; // Why do we need an explicit cast here?
Child childReference = (Child) parentReference; // Or here?
Expand All @@ -86,7 +86,7 @@ public void upCastWithInheritance() {
}

@Koan
public void upCastAndPolymorphism() {
public void downcastAndPolymorphism() {
Grandparent child = new Child();
Parent parent = (Child) child;
// Think about the result. Did you expect that? Why?
Expand Down

0 comments on commit 88d47c9

Please sign in to comment.