-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTask4 (1).java
More file actions
51 lines (46 loc) · 1.46 KB
/
Copy pathTask4 (1).java
File metadata and controls
51 lines (46 loc) · 1.46 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
import java.util.ArrayList;
class Course{
private String Name;
ArrayList<String> list = new <String> ArrayList();
Course(String Name){
this.Name=Name;
}
public void addStudent(String student){
list.add(student);
}
public void dropStudent(String student){
System.out.println(list.remove(student)?"Succesfully drop the student":"Enter the correct name");
}
public ArrayList<String> getList(){
return list;
}
public String getName()
{
return Name;
}
}
public class Task4{
public static void main(String[] args){
Course[] p=new Course[2];
p[0] = new Course("Computer");
p[1] = new Course("English");
Course[] q=new Course[2];
q[0] = new Course("Maths");
q[1] = new Course("OC");
for(int i=0;i<p.length;i++){
p[i].addStudent(i+ "Muhammad Asim");
p[i].dropStudent(i+"Muhammad Asim");
p[i].addStudent(i+"Muhammad Sami");
p[i].dropStudent(i+"Muhammad Sami");
p[i].addStudent(i+"Asad");
System.out.println("No of student in "+p[i].getName()+" is: "+p[i].getList());}
for(int i=0;i<q.length;i++){
q[i].addStudent("Muhammad Nazim");
q[i].dropStudent("Muhammad Nazim");
q[i].addStudent("Muhammad Asad");
q[i].addStudent("Muhammad Sami");
q[i].addStudent("Muhammad Nazim");
q[i].dropStudent("Muhammad Sami");
System.out.println("No of student in "+q[i].getName()+" is: "+q[i].getList());}
}
}