java 定义一个鼠标类
95
2024-03-06 20:45
java
public class Mouse {
private String brand;
private int buttons;
private boolean wireless;
public Mouse(String brand, int buttons, boolean wireless) {
this.brand = brand;
this.buttons = buttons;
this.wireless = wireless;
}
public String getBrand() {
return brand;
}
public void setBrand(String brand) {
this.brand = brand;
}
public int getButtons() {
return buttons;
}
public void setButtons(int buttons) {
this.buttons = buttons;
}
public boolean isWireless() {
return wireless;
}
public void setWireless(boolean wireless) {
this.wireless = wireless;
}
public void click() {
System.out.println("Mouse clicked");
}
public void scroll(int direction) {
System.out.println("Scrolling " + (direction > 0 ? "up" : "down"));
}
}
顶一下
(0)
踩一下
(0)