diff --git a/01_Intellij_Java_universal_20240419/untitled/src/javaAssignment_20240418/box.java b/01_Intellij_Java_universal_20240419/untitled/src/javaAssignment_20240418/box.java index 52a5438..3c0e123 100644 --- a/01_Intellij_Java_universal_20240419/untitled/src/javaAssignment_20240418/box.java +++ b/01_Intellij_Java_universal_20240419/untitled/src/javaAssignment_20240418/box.java @@ -1,5 +1,5 @@ /* - * Function: 盒子类 + * Function: 创建 盒子 类 * Date: 2024 04 18 * Code by: JRNitre * */ @@ -7,30 +7,33 @@ package javaAssignment_20240418; public class box { - double length; - double width; - double height; + private double length; + private double width; + private double height; public void setBox_length (double l){ - length = l; + this.length = l; } public void setBox_width (double w){ - width = w; + this.width = w; } public void setBox_height (double h){ - height = h; + this.height = h; } public void printVolume(){ System.out.println(height * width * length); } public static void main (String[] args){ + // 实例化 box 类 box b_1 = new box(); + // 赋值 b_1.setBox_height(5); b_1.setBox_length(2); b_1.setBox_width(3); + // 输出体积 b_1.printVolume(); } } diff --git a/01_Intellij_Java_universal_20240419/untitled/src/javaAssignment_20240418/complex.java b/01_Intellij_Java_universal_20240419/untitled/src/javaAssignment_20240418/complex.java index 5194ef3..3dd9cd4 100644 --- a/01_Intellij_Java_universal_20240419/untitled/src/javaAssignment_20240418/complex.java +++ b/01_Intellij_Java_universal_20240419/untitled/src/javaAssignment_20240418/complex.java @@ -1,5 +1,5 @@ /* - * Function: 虚数和 + * Function: 创建类计算两个虚数和 * Date: 2024 04 18 * Code by: JRNitre * */ @@ -23,6 +23,7 @@ public class complex { this.imaginePart = i; } + // 计算两个虚数和 public complex complexAdd (complex a){ complex temp = new complex(); temp.realPart = this.realPart + a.realPart; @@ -30,6 +31,7 @@ public class complex { return temp; } + // 返回计算结果 String public String ToString (){ return this.realPart + " + " + this.imaginePart + "i"; } diff --git a/01_Intellij_Java_universal_20240419/untitled/src/javaAssignment_20240418/sumNum.java b/01_Intellij_Java_universal_20240419/untitled/src/javaAssignment_20240418/sumNum.java index ac421f9..8d34fe1 100644 --- a/01_Intellij_Java_universal_20240419/untitled/src/javaAssignment_20240418/sumNum.java +++ b/01_Intellij_Java_universal_20240419/untitled/src/javaAssignment_20240418/sumNum.java @@ -11,6 +11,7 @@ public class sumNum { private int m; // 列 private int n; + // 和 private int sum; // 带参构造方法 @@ -27,6 +28,11 @@ public class sumNum { } } + /** + * Retrieves the sum value. + * + * @return the sum value + */ public int getSum (){ return this.sum; } diff --git a/01_Intellij_Java_universal_20240419/untitled/src/javaAssignment_20240510/thread.java b/01_Intellij_Java_universal_20240419/untitled/src/javaAssignment_20240510/thread.java new file mode 100644 index 0000000..f73be5d --- /dev/null +++ b/01_Intellij_Java_universal_20240419/untitled/src/javaAssignment_20240510/thread.java @@ -0,0 +1,47 @@ +/* + * Function: Java 多线程 + * Date: 2024 05 10 + * Code by: JRNitre + * */ + +package javaAssignment_20240510; + +class myThread extends Thread{ + // 成员变量 + private String who; + // 构造方法 + public myThread(String who){ + super(); + this.who = who; + } + + public myThread(){ + super(); + } + + // 覆盖 run 方法 + public void run(){ + for (int i = 0; i < 5; i++){ + try{ + sleep(1000); + } + catch (InterruptedException e){ + + } + System.out.println(who + "is running"); + } + } +} + +public class thread { + public static void main(String[] args){ + // 创建线程 + myThread test01Thread = new myThread("test01_Thread"); + myThread test02Thread = new myThread("test02_Thread"); + + test01Thread.start(); + test02Thread.start(); + + System.out.println("system out"); + } +} diff --git a/01_Intellij_Java_universal_20240419/untitled/src/javaAssignment_20240514/bus.java b/01_Intellij_Java_universal_20240419/untitled/src/javaAssignment_20240514/bus.java new file mode 100644 index 0000000..afb158a --- /dev/null +++ b/01_Intellij_Java_universal_20240419/untitled/src/javaAssignment_20240514/bus.java @@ -0,0 +1,8 @@ +package javaAssignment_20240514; + +public class bus implements charge{ + @Override + public void charge() { + System.out.println("publicBus: 1$/sheet, No Limit Kilometer"); + } +} diff --git a/01_Intellij_Java_universal_20240419/untitled/src/javaAssignment_20240514/charge.java b/01_Intellij_Java_universal_20240419/untitled/src/javaAssignment_20240514/charge.java new file mode 100644 index 0000000..ca854d0 --- /dev/null +++ b/01_Intellij_Java_universal_20240419/untitled/src/javaAssignment_20240514/charge.java @@ -0,0 +1,5 @@ +package javaAssignment_20240514; + +public interface charge { + public void charge(); +} diff --git a/01_Intellij_Java_universal_20240419/untitled/src/javaAssignment_20240514/cinema.java b/01_Intellij_Java_universal_20240419/untitled/src/javaAssignment_20240514/cinema.java new file mode 100644 index 0000000..265f974 --- /dev/null +++ b/01_Intellij_Java_universal_20240419/untitled/src/javaAssignment_20240514/cinema.java @@ -0,0 +1,13 @@ +package javaAssignment_20240514; + +public class cinema implements play, charge { + @Override + public void play() { + System.out.println("Now Showing"); + } + + @Override + public void charge() { + System.out.println("Cinema: 30$/sheet, Student half"); + } +} diff --git a/01_Intellij_Java_universal_20240419/untitled/src/javaAssignment_20240514/goods.java b/01_Intellij_Java_universal_20240419/untitled/src/javaAssignment_20240514/goods.java new file mode 100644 index 0000000..8d098a1 --- /dev/null +++ b/01_Intellij_Java_universal_20240419/untitled/src/javaAssignment_20240514/goods.java @@ -0,0 +1,19 @@ +package javaAssignment_20240514; + +public class goods { + private String goodsName; + + public goods(String name){ + this.goodsName = name; + } + + // 返回商品名 + public String getName(){ + return this.goodsName; + } + + // 设置商品名 + public void setName(String name){ + this.goodsName = name; + } +} diff --git a/01_Intellij_Java_universal_20240419/untitled/src/javaAssignment_20240514/market.java b/01_Intellij_Java_universal_20240419/untitled/src/javaAssignment_20240514/market.java new file mode 100644 index 0000000..708357a --- /dev/null +++ b/01_Intellij_Java_universal_20240419/untitled/src/javaAssignment_20240514/market.java @@ -0,0 +1,30 @@ +package javaAssignment_20240514; + +public class market { + private String marketName; + private String marketGoodsList; + + public market(String name){ + this.marketName = name; + } + + public String getName(){ + return this.marketName; + } + + public void setName(String name){ + this.marketName = name; + } + + public void getGoodsList(){ + System.out.println(this.marketGoodsList); + } + + public void setGoodsList(String goodlist){ + this.marketGoodsList = goodlist; + } + + public String sell(){ + return "yee~"; + } +} diff --git a/01_Intellij_Java_universal_20240419/untitled/src/javaAssignment_20240514/person.java b/01_Intellij_Java_universal_20240419/untitled/src/javaAssignment_20240514/person.java new file mode 100644 index 0000000..1389b2a --- /dev/null +++ b/01_Intellij_Java_universal_20240419/untitled/src/javaAssignment_20240514/person.java @@ -0,0 +1,23 @@ +package javaAssignment_20240514; + +public class person { + // 姓名 + private String personName; + // 性别 + private String personGender; + // 年龄 + private int personAge; + + public person(String name, String gender, int age){ + this.personName = name; + this.personGender = gender; + this.personAge = age; + } + + public String getInfo(){ + String bunchInfo; + bunchInfo = this.personName + "-" + this.personGender + "-" + this.personAge; + return bunchInfo; + } +} + diff --git a/01_Intellij_Java_universal_20240419/untitled/src/javaAssignment_20240514/person_no3.java b/01_Intellij_Java_universal_20240419/untitled/src/javaAssignment_20240514/person_no3.java new file mode 100644 index 0000000..96f1cd5 --- /dev/null +++ b/01_Intellij_Java_universal_20240419/untitled/src/javaAssignment_20240514/person_no3.java @@ -0,0 +1,17 @@ +package javaAssignment_20240514; + +public class person_no3 { + private String personName; + + public String getName(){ + return this.personName; + } + + public void setName(String name){ + this.personName = name; + } + + public void shopping(){ + System.out.println("rob"); + } +} diff --git a/01_Intellij_Java_universal_20240419/untitled/src/javaAssignment_20240514/play.java b/01_Intellij_Java_universal_20240419/untitled/src/javaAssignment_20240514/play.java new file mode 100644 index 0000000..d10baa2 --- /dev/null +++ b/01_Intellij_Java_universal_20240419/untitled/src/javaAssignment_20240514/play.java @@ -0,0 +1,5 @@ +package javaAssignment_20240514; + +public interface play { + public void play(); +} diff --git a/01_Intellij_Java_universal_20240419/untitled/src/javaAssignment_20240514/student.java b/01_Intellij_Java_universal_20240419/untitled/src/javaAssignment_20240514/student.java new file mode 100644 index 0000000..a769524 --- /dev/null +++ b/01_Intellij_Java_universal_20240419/untitled/src/javaAssignment_20240514/student.java @@ -0,0 +1,42 @@ +package javaAssignment_20240514; + +public class student extends person { + // 学号 + private int studentID; + // 哲学成绩 + private int studentPhilosophyScore; + // 英语成绩 + private int studentEnglishScore; + // 计算机成绩 + private int studentComputerScore; + + // 构造函数 + public student(String name, String gender, int age, int id, int philosophy, int english, int computer) { + super(name, gender, age); + this.studentID = id; + this.studentPhilosophyScore = philosophy; + this.studentEnglishScore = english; + this.studentComputerScore = computer; + } + + // 三门课平均成绩 + public int aver(){ + return (this.studentPhilosophyScore + this.studentEnglishScore + this.studentComputerScore) / 3; + } + + // 最高分 + public double max(){ + return Math.max(Math.max(this.studentComputerScore, this.studentEnglishScore), this.studentPhilosophyScore); + } + + // 最低分 + public int min(){ + return Math.min(Math.min(this.studentComputerScore, this.studentPhilosophyScore), this.studentEnglishScore); + } + + public String getInfo(){ + String bunchInfo; + bunchInfo = this.studentID + "-" + super.getInfo() + "-" + aver() + "-" + max() + "-" + min(); + return bunchInfo; + } +} diff --git a/01_Intellij_Java_universal_20240419/untitled/src/javaAssignment_20240514/taxi.java b/01_Intellij_Java_universal_20240419/untitled/src/javaAssignment_20240514/taxi.java new file mode 100644 index 0000000..f6e6299 --- /dev/null +++ b/01_Intellij_Java_universal_20240419/untitled/src/javaAssignment_20240514/taxi.java @@ -0,0 +1,8 @@ +package javaAssignment_20240514; + +public class taxi implements play{ + @Override + public void play() { + System.out.println("Taxi: 1.6$/Kilometer, Starting 3 Kilometer"); + } +} diff --git a/01_Intellij_Java_universal_20240419/untitled/src/javaAssignment_20240514/test.java b/01_Intellij_Java_universal_20240419/untitled/src/javaAssignment_20240514/test.java new file mode 100644 index 0000000..fbb1ca6 --- /dev/null +++ b/01_Intellij_Java_universal_20240419/untitled/src/javaAssignment_20240514/test.java @@ -0,0 +1,58 @@ +package javaAssignment_20240514; + +public class test{ + + /* + * class: + * person.java + * student.java + public static void main (String[] args){ + student s1 = new student("test", "man", 10, 101, 80, 60, 50); + + System.out.println(s1.getInfo()); + } + */ + + /* + * interface: + * charge.java + * play.java + * class: + * bus.java + * taxi.java + * cinema.java + public static void main (String[] args){ + cinema c1 = new cinema(); + + c1.charge(); + c1.play(); + + bus b1 = new bus(); + b1.charge(); + + taxi t1 = new taxi(); + t1.play(); + } + */ + + public static void main (String[] args){ + goods g1 = new goods("black_man"); + + System.out.println(g1.getName()); + g1.setName("rainbow_main"); + + market m1 = new market("limit"); + + System.out.println(m1.getName()); + m1.setName("no limit"); + m1.setGoodsList("one black_man - two black_man - three black-man"); + m1.getGoodsList(); + System.out.println(m1.sell()); + + person_no3 pn1 = new person_no3(); + + System.out.println(pn1.getName()); + pn1.setName("todd"); + pn1.shopping(); + } +}