forked from Y1ran/JavaSE-Hadoop-Mapred
-
Notifications
You must be signed in to change notification settings - Fork 0
/
List_test(v2).java
57 lines (48 loc) · 1.23 KB
/
List_test(v2).java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package selection;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class List_test {
/*set arr list*/
private ArrayList<Course> coursesToSelect;
private String inp;
private int num;
public int i;
public List_test(){
this.coursesToSelect = new ArrayList<Course>();
while(i < 5) {
this.inp = getChar();
//this.num = getId();
coursesToSelect.add(new Course(i++, this.inp));
}
}
public String getChar() {
Scanner sc = new Scanner(System.in);
System.out.print("Please enter the course:");
String s = sc.next();
return s;
}
public int getId() {
Scanner sc = new Scanner(System.in);
System.out.print("Please enter the id:");
int n = sc.nextInt();
//sc.close();
return n;
}
public void testAdd() {
/*add courses to List*/
//Course c1 = new Course(this.num, this.inp);
//coursesToSelect.add(c1);
//Course temp = coursesToSelect.get(0);
/*System.out.printf("Course %d:%s has been updated", temp.getId()
, temp.getName());
*/
System.out.println("now the course is:");
System.out.println("Course_id " + "Course_Name ");
for(Course c:coursesToSelect)
{
System.out.printf(" %2d | ", c.getId());
System.out.println(c.getName());
}
}
}