View Javadoc
1   package ejava.examples.webtier.bo;
2   
3   import java.io.Serializable;
4   import java.util.Calendar;
5   import java.util.Date;
6   import java.util.GregorianCalendar;
7   
8   public class Grade implements Serializable {
9       private static final long serialVersionUID = 1L;
10      private long id;
11      private String course;
12      private Date semester;
13      private char grade;
14  
15      public Grade() {}
16      public Grade(long id) {
17          setId(id);
18      }
19      public Grade(long id, String course, Date semester, char grade) {
20          setId(id);
21          setCourse(course);
22          setSemester(semester);
23          setGrade(grade);
24      }
25      
26      public long getId() {
27          return id;
28      }
29      private void setId(long id) {
30          this.id = id;
31      }    
32      public String getCourse() {
33          return course;
34      }
35      public void setCourse(String course) {
36          this.course = course;
37      }
38      public char getGrade() {
39          return grade;
40      }
41      public void setGrade(char grade) {
42          this.grade = grade;
43      }
44      public Date getSemester() {
45          return semester;
46      }
47      public void setSemester(Date semester) {
48          this.semester = semester;
49      }
50      
51      public String toString() {
52          Calendar cal = new GregorianCalendar();
53          cal.setTime(semester);
54          StringBuilder text = new StringBuilder();
55          text.append("id=" + id);
56          text.append(", course=" + course);
57          text.append(", semester=" + cal.get(Calendar.MONTH) + "-" +
58                  cal.get(Calendar.YEAR));
59          text.append(", grade=" + grade);
60          return text.toString();
61      }
62  
63  }