2026.6.3

1、

点击查看代码
public class Refrigerator {
    String brand;
    String color;
    double capacity;
    boolean isOn;
    public void openDoor(){
        System.out.println(color+"的"+brand+"冰箱门打开了");
        coolDown(4);
    }
    private void coolDown(int temp){
        System.out.println("【内部运作】正在启动压缩机,设定温度:“+temp+度");
    }
}
2、
点击查看代码
public class Main {
    public static void main(String[] args) {
        //TIP Press <shortcut actionId="ShowIntentionActions"/> with your caret at the highlighted text
        // to see how IntelliJ IDEA suggests fixing it.
        Student stu = new Student();
        stu.name = "王宁梓";
        stu.id = 723410628;
        stu.age = 20;
        stu.study();
        stu.exam();
        stu.displayInfo();
    }
}
class Student {
    String name;
    int id;
    int age;
    public void study(){
        System.out.println(name+"正在学习");
    }
    public void exam(){
        System.out.println(name+"正在考试");
    }
    public void displayInfo(){
        System.out.println("姓名;"+name+",学号;"+id+",年龄;"+age);
    }
}
3、
点击查看代码

posted @ 2026-06-04 15:00  Daisy!  阅读(6)  评论(0)    收藏  举报