把test.java救回来了

This commit is contained in:
2024-06-11 01:53:01 +08:00
parent d085000064
commit d753356d40
54 changed files with 1309 additions and 1297 deletions
+7 -7
View File
@@ -1,7 +1,7 @@
{
"java.project.sourcePaths": ["src"],
"java.project.outputPath": "bin",
"java.project.referencedLibraries": [
"lib/**/*.jar"
]
}
{
"java.project.sourcePaths": ["src"],
"java.project.outputPath": "bin",
"java.project.referencedLibraries": [
"lib/**/*.jar"
]
}
+18 -18
View File
@@ -1,18 +1,18 @@
## Getting Started
Welcome to the VS Code Java world. Here is a guideline to help you get started to write Java code in Visual Studio Code.
## Folder Structure
The workspace contains two folders by default, where:
- `src`: the folder to maintain sources
- `lib`: the folder to maintain dependencies
Meanwhile, the compiled output files will be generated in the `bin` folder by default.
> If you want to customize the folder structure, open `.vscode/settings.json` and update the related settings there.
## Dependency Management
The `JAVA PROJECTS` view allows you to manage your dependencies. More details can be found [here](https://github.com/microsoft/vscode-java-dependency#manage-dependencies).
## Getting Started
Welcome to the VS Code Java world. Here is a guideline to help you get started to write Java code in Visual Studio Code.
## Folder Structure
The workspace contains two folders by default, where:
- `src`: the folder to maintain sources
- `lib`: the folder to maintain dependencies
Meanwhile, the compiled output files will be generated in the `bin` folder by default.
> If you want to customize the folder structure, open `.vscode/settings.json` and update the related settings there.
## Dependency Management
The `JAVA PROJECTS` view allows you to manage your dependencies. More details can be found [here](https://github.com/microsoft/vscode-java-dependency#manage-dependencies).
+21 -21
View File
@@ -1,21 +1,21 @@
//Student.java
package test1;
public class Student {
int id;
int age;
int grade;
public void study() {
System.err.println("学号为" + id + "的学生正在学习");
}
public void examination() {
System.err.println(id + "年级正在考试");
}
public void tell() {
System.out.print("正在讲话的是一个" + age + "岁的学生");
}
}
//Student.java
package test1;
public class Student {
int id;
int age;
int grade;
public void study() {
System.err.println("学号为" + id + "的学生正在学习");
}
public void examination() {
System.err.println(id + "年级正在考试");
}
public void tell() {
System.out.print("正在讲话的是一个" + age + "岁的学生");
}
}
+14 -14
View File
@@ -1,14 +1,14 @@
//test.java
package test1;
public class test {
public static void main(String[] args) {
Student s1 = new Student();
s1.id = 001;
s1.age = 18;
s1.grade = 1;
s1.study();
s1.examination();
s1.tell();
}
}
//test.java
package test1;
public class test {
public static void main(String[] args) {
Student s1 = new Student();
s1.id = 001;
s1.age = 18;
s1.grade = 1;
s1.study();
s1.examination();
s1.tell();
}
}
+16 -16
View File
@@ -1,16 +1,16 @@
//Circle.java
package test2;
public class Circle {
double radius;
double area;
public void set(double radius) {
this.radius = radius;
}
public void disaplay() {
area = radius * radius * 3.14;
System.err.println("This circle's radius is " + radius + ", area is " + area);
}
}
//Circle.java
package test2;
public class Circle {
double radius;
double area;
public void set(double radius) {
this.radius = radius;
}
public void disaplay() {
area = radius * radius * 3.14;
System.err.println("This circle's radius is " + radius + ", area is " + area);
}
}
+21 -21
View File
@@ -1,21 +1,21 @@
//Cone.java
package test2;
public class Cone {
double buttom;
double height;
public void set(double buttom, double height) {
this.buttom = buttom;
this.height = height;
}
public Cone() {
}
public void disaplay() {
System.out.println(
"This cone's buttom area is " + buttom + ", height is " + height + ", volume is "
+ buttom * height / 3);
}
}
//Cone.java
package test2;
public class Cone {
double buttom;
double height;
public void set(double buttom, double height) {
this.buttom = buttom;
this.height = height;
}
public Cone() {
}
public void disaplay() {
System.out.println(
"This cone's buttom area is " + buttom + ", height is " + height + ", volume is "
+ buttom * height / 3);
}
}
+14 -14
View File
@@ -1,14 +1,14 @@
//test.java
package test2;
public class test {
public static void main(String[] args) {
Circle r1 = new Circle();
r1.set(3);
r1.disaplay();
Cone c1 = new Cone();
c1.set(28.26, 5);
c1.disaplay();
}
}
//test.java
package test2;
public class test {
public static void main(String[] args) {
Circle r1 = new Circle();
r1.set(3);
r1.disaplay();
Cone c1 = new Cone();
c1.set(28.26, 5);
c1.disaplay();
}
}
+33 -33
View File
@@ -1,33 +1,33 @@
//Student.java
package test3;
public class Student {
private int age;
private String sex;
// setters
public void setAge(int age) {
if (age >= 0 & age <= 120) {
this.age = age;
} else {
this.age = 18;
}
}
public void setSex(String sex) {
if ("".equals(sex) || "".equals(sex)) {
this.sex = sex;
} else {
this.sex = "保密";
}
}
// getters
public int getAge() {
return age;
}
public String getSex() {
return sex;
}
}
//Student.java
package test3;
public class Student {
private int age;
private String sex;
// setters
public void setAge(int age) {
if (age >= 0 & age <= 120) {
this.age = age;
} else {
this.age = 18;
}
}
public void setSex(String sex) {
if ("".equals(sex) || "".equals(sex)) {
this.sex = sex;
} else {
this.sex = "保密";
}
}
// getters
public int getAge() {
return age;
}
public String getSex() {
return sex;
}
}
+14 -14
View File
@@ -1,14 +1,14 @@
//test.java
package test3;
import java.util.Scanner;
public class test {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
Student s1 = new Student();
s1.setAge(input.nextInt());
s1.setSex(input.next());
System.out.println("This student's age is " + s1.getAge() + ", gender is " + s1.getSex());
}
}
//test.java
package test3;
import java.util.Scanner;
public class test {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
Student s1 = new Student();
s1.setAge(input.nextInt());
s1.setSex(input.next());
System.out.println("This student's age is " + s1.getAge() + ", gender is " + s1.getSex());
}
}
+20 -20
View File
@@ -1,20 +1,20 @@
//Yard.java
package test4;
public class Yard {
double length;
double width;
public Yard(double length, double width) {
this.length = length;
this.width = width;
}
public double getPerimeter() {
return (length + width) * 2;
}
public double getAcreage() {
return length * width;
}
}
//Yard.java
package test4;
public class Yard {
double length;
double width;
public Yard(double length, double width) {
this.length = length;
this.width = width;
}
public double getPerimeter() {
return (length + width) * 2;
}
public double getAcreage() {
return length * width;
}
}
+12 -12
View File
@@ -1,12 +1,12 @@
//test.java
package test4;
import java.util.Scanner;
public class test {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
Yard y1 = new Yard(input.nextDouble(), input.nextDouble());
System.err.println(y1.getPerimeter()+" "+y1.getAcreage());
}
}
//test.java
package test4;
import java.util.Scanner;
public class test {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
Yard y1 = new Yard(input.nextDouble(), input.nextDouble());
System.err.println(y1.getPerimeter()+" "+y1.getAcreage());
}
}
+25 -25
View File
@@ -1,25 +1,25 @@
//Employee.java
package test5;
public class Employee {
String name;
int age;
String dept;
static String company;
public void showInfos() {
System.out.println("name\t" + name);
System.out.println("age\t" + age);
System.out.println("dept\t" + dept);
System.out.println("company\t" + company);
System.out.println();
}
public static int compareAge(int age1, int age2) {
if (age1 > age2) {
return age1;
} else {
return age2;
}
}
}
//Employee.java
package test5;
public class Employee {
String name;
int age;
String dept;
static String company;
public void showInfos() {
System.out.println("name\t" + name);
System.out.println("age\t" + age);
System.out.println("dept\t" + dept);
System.out.println("company\t" + company);
System.out.println();
}
public static int compareAge(int age1, int age2) {
if (age1 > age2) {
return age1;
} else {
return age2;
}
}
}
+19 -19
View File
@@ -1,19 +1,19 @@
//test.java
package test5;
public class test {
public static void main(String[] args) {
Employee e1 = new Employee();
e1.name = "Jack";
e1.age = 30;
e1.dept = "Software";
Employee.company = "XJIT.inc";
e1.showInfos();
Employee e2 = new Employee();
e2.name = "Mike";
e2.age = 45;
e2.dept = "Hardware";
e2.showInfos();
System.out.println("2个人中最大年龄是" + Employee.compareAge(e1.age, e2.age) + "岁。");
}
}
//test.java
package test5;
public class test {
public static void main(String[] args) {
Employee e1 = new Employee();
e1.name = "Jack";
e1.age = 30;
e1.dept = "Software";
Employee.company = "XJIT.inc";
e1.showInfos();
Employee e2 = new Employee();
e2.name = "Mike";
e2.age = 45;
e2.dept = "Hardware";
e2.showInfos();
System.out.println("2个人中最大年龄是" + Employee.compareAge(e1.age, e2.age) + "岁。");
}
}