-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSubject.java
More file actions
81 lines (73 loc) · 1.64 KB
/
Subject.java
File metadata and controls
81 lines (73 loc) · 1.64 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
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package Classes;
import java.io.Serializable;
import java.util.Vector;
/**
*
* @author NIRKA
*/
public class Subject implements Serializable {
private Vector v;
private String name;
private Integer maxMark;
public Subject()
{
v=new Vector();
}
public Subject(String name,Integer maxMark)
{
this.name =name;
v=new Vector();
this.maxMark = maxMark;
if(maxMark < 0)
maxMark=100;
}
public Integer getMaxMark()
{
return this.maxMark;
}
public Integer getMark()
{
Integer sum=0;
for(int i=0;i<v.size();i++)
{
Event ev = (Event)v.elementAt(i);
if(ev.isHappened())
sum+=ev.getMark();
}
return sum;
}
@Override
public String toString()
{
return this.name;
}
@Override
public boolean equals(Object o)
{
return this.hashCode() == o.hashCode();
}
@Override
public int hashCode() {
int hash = 7;
hash = 41 * hash + (this.v != null ? this.v.hashCode() : 0);
hash = 41 * hash + (this.name != null ? this.name.hashCode() : 0);
hash = 41 * hash + (this.maxMark != null ? this.maxMark.hashCode() : 0);
return hash;
}
public Integer getNumberEvents()
{
return this.v.size();
}
public Event getEventAt(int index)
{
return (Event)this.v.elementAt(index);
}
public void addEvent(Event e)
{
v.addElement(e);
}
}