-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This reverts commit c374f7a.
- Loading branch information
Showing
4 changed files
with
22 additions
and
36 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,17 @@ | ||
package com.github.hcsp.inheritance; | ||
|
||
public class Cat extends Animal{ | ||
public class Cat { | ||
private String name; | ||
|
||
public Cat(String name) { | ||
super(name); | ||
this.name = name; | ||
} | ||
|
||
public void meow() { | ||
super.call("喵"); | ||
public void sayMyName() { | ||
System.out.println("我的名字是" + name); | ||
} | ||
|
||
public void meow() { | ||
System.out.println("喵" + name); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,17 @@ | ||
package com.github.hcsp.inheritance; | ||
|
||
public class Dog extends Animal{ | ||
public class Dog { | ||
private String name; | ||
|
||
public Dog(String name) { | ||
super(name); | ||
this.name = name; | ||
} | ||
|
||
|
||
public void sayMyName() { | ||
System.out.println("我的名字是" + name); | ||
} | ||
|
||
public void wang() { | ||
super.call("汪"); | ||
System.out.println("汪" + name); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,17 @@ | ||
package com.github.hcsp.inheritance; | ||
|
||
public class Rat extends Animal{ | ||
public class Rat { | ||
private String name; | ||
|
||
public Rat(String name) { | ||
super(name); | ||
this.name = name; | ||
} | ||
|
||
|
||
public void sayMyName() { | ||
System.out.println("我的名字是" + name); | ||
} | ||
|
||
public void zhizhi() { | ||
super.call("吱吱"); | ||
System.out.println("吱吱" + name); | ||
} | ||
|
||
} |