Skip to content

Commit 089edda

Browse files
committed
day10
1 parent 8da3cc6 commit 089edda

File tree

12 files changed

+134
-0
lines changed

12 files changed

+134
-0
lines changed

practice/test/.vscode/launch.json

+21
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,27 @@
44
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
55
"version": "0.2.0",
66
"configurations": [
7+
{
8+
"type": "java",
9+
"name": "Launch maopao",
10+
"request": "launch",
11+
"mainClass": "day10.maopao",
12+
"projectName": "test_a0501e95"
13+
},
14+
{
15+
"type": "java",
16+
"name": "Launch ComputerTest",
17+
"request": "launch",
18+
"mainClass": "day10.ComputerTest",
19+
"projectName": "test_a0501e95"
20+
},
21+
{
22+
"type": "java",
23+
"name": "Launch testdemo",
24+
"request": "launch",
25+
"mainClass": "day10.OuterInner.testdemo",
26+
"projectName": "test_a0501e95"
27+
},
728
{
829
"type": "java",
930
"name": "Launch PersonDemo",
803 Bytes
Binary file not shown.
Binary file not shown.
413 Bytes
Binary file not shown.
687 Bytes
Binary file not shown.
Binary file not shown.

practice/test/bin/day10/maopao.class

2.07 KB
Binary file not shown.
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package day10;
2+
3+
public class ComputerTest {
4+
public static void main(String[] args) {
5+
long total = 0;
6+
for (int j = 0; j < 101; j++) {
7+
long start = System.currentTimeMillis();
8+
for (int i = 0; i < 1000; i++) {
9+
System.out.println(i);
10+
}
11+
long end = System.currentTimeMillis();
12+
total += (end - start);
13+
}
14+
System.out.println(total/100);
15+
}
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package day10.OuterInner;
2+
3+
public class Outer {
4+
5+
private int age = 10;
6+
7+
public class Inner {
8+
public void show() {
9+
System.out.println(age);
10+
}
11+
}
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package day10.OuterInner;
2+
3+
public class testdemo {
4+
public static void main(String[] args) {
5+
Outer.Inner oi = new Outer().new Inner();
6+
oi.show();
7+
}
8+
}

practice/test/src/day10/PlayerAndCoach/PersonDemo.java

+13
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
package day10.PlayerAndCoach;
2+
/*
3+
①定义说英语接口 成员方法:说英语();
4+
②定义抽象人类 成员变量:姓名,年龄;构造方法:无参,带参;成员方法:get/set方法,吃饭(;
5+
③定义抽象教练类,继承人类 构造方法:无参,带参;成员方法:教();
6+
④定义抽象运动员类,继承人类 构造方法:无参,带参;成员方法:学习);
7+
⑤定义具体篮球教练类,继承教练类 构造方法:无参,带参;成员方法:重写吃饭(){...},重写教(){..}
8+
⑥定义具体乒乓球教练类,继承教练类,实现说英语接口
9+
构造方法:无参,带参;成员方法:重写吃饭(){...},重写教(){...},重写说英语(){.….}
10+
⑦定义具体篮球运动员类,继承运动员类 构造方法:无参,带参;成员方法:重写吃饭(){.....},重写学习(){…}
11+
⑧定义具体乒乓球运动员类,继承运动员类,实现说英语接口
12+
构造方法:无参,带参;成员方法:重写吃饭(){...},重写学习(){...},重写说英语(){..}
13+
⑨定义测试类,写代码测试
214
15+
*/
316
public class PersonDemo {
417
public static void main(String[] args) {
518
PingPangPlayer ppp = new PingPangPlayer();

practice/test/src/day10/maopao.java

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
package day10;
2+
3+
import java.util.Scanner;
4+
5+
public class maopao {
6+
public static void main(String[] args) {
7+
Scanner sc = new Scanner(System.in);
8+
System.out.print("Please input how much numbers you have:");
9+
int n = sc.nextInt();
10+
int[] num = new int[n];
11+
for (int i = 0; i < num.length; i++) {
12+
String s = Ordinal(i + 1);
13+
System.out.print("Please input the " + s + " number:");
14+
num[i] = sc.nextInt();
15+
}
16+
System.out.print("Before sorting: ");
17+
PrintArr(num);
18+
19+
int temp;
20+
for (int i = 0; i < num.length - 1; i++) {
21+
for (int j = 0; j < num.length - 1 - i; j++) {
22+
if (num[j] < num[j + 1]) {
23+
temp = num[j];
24+
num[j] = num[j + 1];
25+
num[j + 1] = temp;
26+
}
27+
}
28+
}
29+
System.out.print("After sorting: ");
30+
PrintArr(num);
31+
sc.close();
32+
}
33+
34+
public static void PrintArr(int[] num) {
35+
System.out.print("[");
36+
for (int i = 0; i < num.length; i++) {
37+
if (i == num.length - 1) {
38+
System.out.print(num[i]);
39+
} else {
40+
System.out.print(num[i] + ", ");
41+
}
42+
}
43+
System.out.println("]");
44+
}
45+
46+
public static String Ordinal(int a) {
47+
String ord;
48+
switch (a % 10) {
49+
case 1:
50+
ord = a + "st";
51+
break;
52+
case 2:
53+
ord = a + "nd";
54+
break;
55+
case 3:
56+
ord = a + "rd";
57+
break;
58+
default:
59+
ord = a + "th";
60+
break;
61+
}
62+
return ord;
63+
}
64+
}

0 commit comments

Comments
 (0)