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

setter and getter #268

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
30 changes: 28 additions & 2 deletions src/main/java/com/github/hcsp/encapsulation/Cat.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,36 @@
package com.github.hcsp.encapsulation;

public class Cat {

/** 猫咪的名字 */
public String name;
private String name;
/** 猫咪的年龄 */
public int age;
private int age;
/** 猫咪是否萌,true为萌,false为不萌 */

public boolean cute;
public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public int getAge() {
return age;
}

public void setAge(int age) {
this.age = age;
}

public boolean isCute() {
return cute;
}

public void setCute(boolean cute) {
this.cute = cute;
}

}