把test.java救回来了
This commit is contained in:
+21
-21
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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) + "岁。");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user