Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Geng #250

Closed
wants to merge 2 commits into from
Closed

Geng #250

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
8 changes: 3 additions & 5 deletions src/main/java/com/github/hcsp/inheritance/Cat.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
package com.github.hcsp.inheritance;

public class Cat {
public class Cat extends Animal{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'{' 前应有空格。


private String name;

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

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

public void meow() {
Expand Down
8 changes: 3 additions & 5 deletions src/main/java/com/github/hcsp/inheritance/Dog.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
package com.github.hcsp.inheritance;

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

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

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


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

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

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

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


public void zhizhi() {
System.out.println("吱吱" + name);
}
Expand Down