diff --git a/work/com/java/minxi/java_20240420/Demo1.java b/work/com/java/minxi/java_20240420/Demo1.java new file mode 100644 index 0000000000000000000000000000000000000000..5720591fc6b9d6afcf3774e7f4db7817c8111e72 --- /dev/null +++ b/work/com/java/minxi/java_20240420/Demo1.java @@ -0,0 +1,97 @@ +package com.java.minxi.java_20240420; + +public class Demo1 { + String brand; + int weight; + String type; + + + public static class Demo2 { + String brand; + String type; + + public Demo2(){ + + } + + public Demo2(String brand,String type){ + this.brand=brand; + this.type=type; + } + + public void refrigeration(){ + System.out.println(this.brand+this.type+"正在"+"制冷"); + } + public void heating(){ + System.out.println(this.brand+this.type+"正在"+"制热"); + } + + public void setBrand(String brand){ + this.brand=brand; + } + + public void setType(String type){ + this.type=type; + } + + public String getBrand(){ + return brand; + } + + public String getType(){ + return type; + } + + + + + + } + + public void clothes(){ + System.out.println(this.brand+this.type+"正在洗衣服"); + } + + public void cooking(){ + System.out.println(this.brand+this.type+"正在炖鸡汤"); + } + + public void weigh(){ + System.out.println(this.brand+this.type+"有"+this.weight+"kg重"); + } + + public void setBrand(String brand){ + this.brand=brand; + } + public void setWeight(int weight){ + this.weight=weight; + } + public void setType(String type){ + this.type=type; + } + public String getBrand(){ + return brand; + } + + public int getWeight(){ + return weight; + } + + public String getType(){ + return type; + } + + public Demo1(){ + + } + + public Demo1(String brand, int weight, String type){ + this.brand=brand; + this.weight=weight; + this.type=type; + } + + + } + + diff --git a/work/com/java/minxi/java_20240420/Demo3.java b/work/com/java/minxi/java_20240420/Demo3.java new file mode 100644 index 0000000000000000000000000000000000000000..c1d7c4458bc2b59ad1c53c89018478631530c006 --- /dev/null +++ b/work/com/java/minxi/java_20240420/Demo3.java @@ -0,0 +1,64 @@ +package com.java.minxi.java_20240420; + +public class Demo3 { + + public static void main(String[] args) { + Demo1 wash=new Demo1(); + wash.brand="海尔"; + wash.type="洗衣机"; + wash.clothes(); + + Demo1 cook=new Demo1(); + cook.brand="美的"; + cook.type="电饭煲"; + cook.cooking(); + + Demo1 wei=new Demo1(); + wei.brand="海尔"; + wei.type="冰箱"; + wei.weight=50; + wei.weigh(); + + Demo1.Demo2 dj=new Demo1.Demo2(); + dj.brand="大金"; + dj.type="空调"; + dj.refrigeration(); + + + + Demo1 wash1=new Demo1(); + wash1.setBrand("海尔"); + wash1.setType("洗衣机"); + wash1.clothes(); + + Demo1 cook1=new Demo1(); + cook1.setBrand("美的"); + cook1.setType("电饭煲"); + cook1.cooking(); + + Demo1 wei1=new Demo1(); + wei1.setBrand("海尔"); + wei1.setType("冰箱"); + wei1.weight=50; + wei.weigh(); + + Demo1.Demo2 dj1=new Demo1.Demo2(); + dj1.setBrand("大金"); + dj1.setType("空调"); + + Demo1 wash2=new Demo1("海尔",75,"洗衣机"); + wash2.clothes(); + + Demo1 cook2=new Demo1("美的",2,"电饭锅"); + cook2.cooking(); + + Demo1 wei2=new Demo1("海尔",50,"冰箱"); + wei2.weigh(); + + Demo1.Demo2 dj2=new Demo1.Demo2("大金","空调"); + dj.refrigeration(); + + } + } + +