-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCourse.java
More file actions
86 lines (80 loc) · 1.89 KB
/
Copy pathCourse.java
File metadata and controls
86 lines (80 loc) · 1.89 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import java.util.*;
public class Course
{
private String name;
private Faculty f;
private Student[] s;
private int count;
public Course(){
name = "Default";
f = new Faculty();
count = 3;
s = new Student[50];
for(int i = 0; i < count; i++){
s[i] = new Student();
}
}
public Course(String name, Faculty f, int count){
this.name = name;
this.f = f;
this.count = count;
s = new Student[50];
for(int i = 0; i < count; i++){
s[i] = new Student();
}
}
public String getName(){
return name;
}
public Faculty getFaculty(){
return f;
}
public String getStudent(int index){
if(index < count - 1){
return s[index].toString();
}else{
return "Error. Input Validation Error.";
}
}
public int getCount(){
return count;
}
public void setName(String name){
this.name = name;
}
public void setFaculty(Faculty f){
this.f = f;
}
public int setStudent(Student newS){
if(count >= 50){
return -1;
}
s[count] = newS;
count++;
return count - 1;
}
public int setStudent(Student newS, int i){
if(i >= 50){
return -1;
}
else if(i > count){
s[count] = newS;
count++;
return count - 1;
}
else{
s[i] = newS;
return i;
}
}
public String printStudents(){
String answer = "";
for(int i = 0; i < count; i++){
answer += s[i].toString() + "\n\n";
}
return answer;
}
public String toString(){
return "Course Name: " + name + " \n" + f.toString() + " \nNumber of Students: " + count;
}
}