Skip to content

Commit

Permalink
Revert "添加一个父类来继承 (#247)"
Browse files Browse the repository at this point in the history
This reverts commit 1733d77.
  • Loading branch information
hcsp-bot committed Nov 22, 2021
1 parent 1733d77 commit df905d3
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 13 deletions.
9 changes: 0 additions & 9 deletions src/main/java/com/github/hcsp/inheritance/Animal.java

This file was deleted.

7 changes: 6 additions & 1 deletion src/main/java/com/github/hcsp/inheritance/Cat.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
package com.github.hcsp.inheritance;

public class Cat extends Animal{
public class Cat {
private String name;

public Cat(String name) {
this.name = name;
}

public void sayMyName() {
System.out.println("我的名字是" + name);
}

public void meow() {
System.out.println("喵" + name);
}
Expand Down
7 changes: 6 additions & 1 deletion src/main/java/com/github/hcsp/inheritance/Dog.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
package com.github.hcsp.inheritance;

public class Dog extends Animal{
public class Dog {
private String name;

public Dog(String name) {
this.name = name;
}

public void sayMyName() {
System.out.println("我的名字是" + name);
}

public void wang() {
System.out.println("汪" + name);
}
Expand Down
9 changes: 7 additions & 2 deletions src/main/java/com/github/hcsp/inheritance/Rat.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
package com.github.hcsp.inheritance;

public class Rat extends Animal{
public class Rat {
private String name;

public Rat(String name) {
super.name = name;
this.name = name;
}

public void sayMyName() {
System.out.println("我的名字是" + name);
}

public void zhizhi() {
Expand Down

0 comments on commit df905d3

Please sign in to comment.