-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTopics.java
More file actions
87 lines (69 loc) · 2.13 KB
/
Topics.java
File metadata and controls
87 lines (69 loc) · 2.13 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
87
import java.io.FileWriter; // Import the FileWriter class
import java.io.IOException; // Import the IOException class to handle errors
import java.util.*;
public class Topics {
private int id;
private String name;
private ArrayList<CLO> clos = new ArrayList<CLO>();
/////////filing param//////
private ArrayList<Integer> closIds = new ArrayList<Integer>();
//constructor
public Topics( int id,String name, ArrayList<CLO> clos,ArrayList<Integer> closIds) {
this.id = id;
this.name = name;
this.clos = clos;
this.closIds=closIds;
}
//print topic
public void PrintTopic() {
System.out.println("ID: "+id);
System.out.println("Title: "+name);
if(clos!=null) {
for (int i = 0; i < clos.size(); i++)
System.out.print("CLO " + clos.get(i).getId() + " ");
System.out.print(" ||| ");
}
if(closIds!=null) {
for (int i = 0; i < closIds.size(); i++)
System.out.print("CLOIds " + closIds.get(i)+ " ");
}
System.out.println('\n');
}
////custom functions
public void assignCLO(CLO clo) {
if(!clos.contains(clo)) {
if(this.clos==null)
this.clos=new ArrayList<>();
if(this.closIds==null)
this.closIds=new ArrayList<>();
this.clos.add(clos.size(), clo);
this.closIds.add(closIds.size(),clo.getId());
}
else System.out.println("You are trying to assign same CLO again");
}
//////getters setters
public void setClos(ArrayList<CLO> clos) {
this.clos = clos;
}
public void setClosIds(ArrayList<Integer> closIds) {
this.closIds = closIds;
}
public ArrayList<CLO> getClos() {
return clos;
}
public ArrayList<Integer> getClosIds() {
return closIds;
}
public int getId() {
return id;
}
public String getName() {
return name;
}
public void setId(int id) {
this.id = id;
}
public void setName(String name) {
this.name = name;
}
}