day06-面向对象类的标准代码JavaBean的规范和快捷键
This commit is contained in:
53
day06/src/com/inmind/constructor03/Cat.java
Normal file
53
day06/src/com/inmind/constructor03/Cat.java
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
package com.inmind.constructor03;
|
||||||
|
|
||||||
|
public class Cat {
|
||||||
|
//属性
|
||||||
|
private String name;
|
||||||
|
private int age;
|
||||||
|
private String color;
|
||||||
|
|
||||||
|
//构造方法
|
||||||
|
//alt+insert
|
||||||
|
public Cat() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public Cat(String name, int age, String color) {
|
||||||
|
this.name = name;
|
||||||
|
this.age = age;
|
||||||
|
this.color = color;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Cat(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
//getter和setter方法
|
||||||
|
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 String getColor() {
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setColor(String color) {
|
||||||
|
this.color = color;
|
||||||
|
}
|
||||||
|
|
||||||
|
//行为
|
||||||
|
public void catchMouse() {
|
||||||
|
System.out.println("抓老鼠");
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user