day06-面向对象类的标准代码JavaBean的规范和快捷键

This commit is contained in:
2026-05-10 15:24:10 +08:00
parent 70585d8d65
commit 8526e31417

View 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("抓老鼠");
}
}