diff --git "a/work/com/java/minxi/java_20240422/java_2301_\347\216\213\346\230\276\344\271\211_2344310134/Electric134.java" "b/work/com/java/minxi/java_20240422/java_2301_\347\216\213\346\230\276\344\271\211_2344310134/Electric134.java" new file mode 100644 index 0000000000000000000000000000000000000000..619e47b72bb8f90e34ee9fc1ca4f01221986ab3d --- /dev/null +++ "b/work/com/java/minxi/java_20240422/java_2301_\347\216\213\346\230\276\344\271\211_2344310134/Electric134.java" @@ -0,0 +1,152 @@ +package com.java.minxi.java_20240422.java_2301_王显义_2344310134; + +public class Electric134 { + /* + *成员变量 + * + * */ + + + String breed;//品牌 + + int weight;//重量 + + String type;//类别 + + + + /* + *方法 + * */ + +// 洗衣服 + public void wash(){ + System.out.println(breed+type+"正在洗衣服"); + } + +// 做饭 + public void cook(){ + System.out.println(breed+type+"正在炖鸡汤"); + } + +// 称重 + public void weight(){ + System.out.println(breed+type+"有"+weight+"kg重"); + } + +// 品牌赋值 + public void setBreed(String breed){ + this.breed=breed; + } +// 品牌取值 + public String getBreed(){ + return breed; + } +// 重量赋值 + public void setWeight(int weight){ + this.weight=weight; + } +// 重量取值 + public int getWeight(){ + return weight; + } +// 类别赋值 + public void setType(String type){ + this.type=type; + } +// 类别取值 + public String getType(){ + return type; + } + + + + /* + * 构造方法 + * */ + + + +// 无参构造方法 + Electric134(){ + + } + +// 有参构造方法 + Electric134(String breed, String type, int weight){ + this.type=type; + this.weight=weight; + this.breed=breed; + } + + + +// 空调静态内部类 + public static class Interior{ + String breed;//品牌 + + String type;//类别 + + + + /* + *内部类方法 + * */ + + +// 制冷 + public void cold(){ + System.out.println(breed+type+"正在制冷"); + } + + +// 制热 + public void hot(){ + System.out.println(breed+type+"正在制热"); + } + +// 品牌赋值 + public void setBreed(String breed){ + this.breed=breed; + } + +// 品牌取值 + public String getBreed(){ + return breed; + } + +// 类别赋值 + public void setType(String type){ + this.type=type; + } + +// 类别取值 + public String getType(){ + return type; + } + + /* + * 内部类构造方法 + * */ + + + +// 无参构造方法 + Interior(){ + + } + +// 有参构造方法 + Interior(String breed,String type){ + this.type=type; + this.breed=breed; + } + + + + } + + + + +} diff --git "a/work/com/java/minxi/java_20240422/java_2301_\347\216\213\346\230\276\344\271\211_2344310134/Electric134_info.java" "b/work/com/java/minxi/java_20240422/java_2301_\347\216\213\346\230\276\344\271\211_2344310134/Electric134_info.java" new file mode 100644 index 0000000000000000000000000000000000000000..2f7b9865fc552f75a78e43625bf5c0c16d23027d --- /dev/null +++ "b/work/com/java/minxi/java_20240422/java_2301_\347\216\213\346\230\276\344\271\211_2344310134/Electric134_info.java" @@ -0,0 +1,86 @@ +package com.java.minxi.java_20240422.java_2301_王显义_2344310134; + +import javax.xml.transform.Source; + +public class Electric134_info { + public static void main(String[] args) { +// 使用简单的对象调用属性方式对属性赋值并在控制台中输出 + Electric134 el1 =new Electric134(); + + el1.breed="海尔"; + el1.type="洗衣机"; + el1.wash(); + + Electric134 el2 =new Electric134(); + + el2.breed="美的"; + el2.type="电饭锅"; + el2.cook(); + + Electric134 el3 =new Electric134(); + + el3.breed="海尔"; + el3.weight=50; + el3.type="冰箱"; + el3.weight(); + + Electric134.Interior el4 =new Electric134.Interior(); + + el4.breed="大金"; + el4.type="空调"; + el4.cold(); + + System.out.println(" "); +// 使用实例方法的方式对属性赋值并在控制台中输出 + + Electric134 el11 =new Electric134(); + + el11.setBreed("海尔"); + el11.setType("洗衣机"); + el11.wash(); + + Electric134 el22 =new Electric134(); + + el22.setBreed("美的"); + el22.setType("电饭锅"); + el22.cook(); + + Electric134 el33 = new Electric134(); + + el33.setBreed("海尔"); + el33.setWeight(50); + el33.setType("冰箱"); + el33.weight(); + + Electric134.Interior el44 = new Electric134.Interior(); + + el44.setBreed("大金"); + el44.setType("空调"); + el44.cold(); + + + System.out.println(" "); + +// 使用构造方法的方式对属性赋值并在控制台中输出 + + + + Electric134 el111 = new Electric134("海尔", "洗衣机", 0); + el111.wash(); + + Electric134 el222 = new Electric134("美的","电饭锅",0); + el222.cook(); + + Electric134 el333 = new Electric134("海尔","冰箱",50); + el333.weight(); + + Electric134.Interior el444 = new Electric134.Interior("大金","空调"); + el444.cold(); + + + + + + + } +}