root/okpoll/src/net/okjsp/poll/Poll.java

리비전 5, 0.9 kB (mefour에 의해 체크인됨, 16 년 전)

--

  • svn:mime-type 속성이 text/plain (으)로 설정되어있습니다.
Line 
1 package net.okjsp.poll;
2
3 import java.util.ArrayList;
4
5 public class Poll {
6        
7         private int id;
8        
9         private String question;
10
11         private ArrayList<Item> items;
12
13
14         public void setQuestion(String question) {
15                 this.question = question;
16         }
17        
18         public String getQuestion() {
19                 return this.question;
20         }
21
22         public ArrayList<Item> getItems() {
23                 return items;
24         }
25        
26         public void setItems(ArrayList<Item> items) {
27                 int idx = 0;
28                 for (Item item : items) {
29                         item.setId(idx++);
30                 }
31                 this.items = items;
32         }
33
34         public void setId(int id) {
35                 this.id = id;
36         }
37
38         public int getId() {
39                 return id;
40         }
41
42         public int increment(int itemId) {
43                 for (Item item : items) {
44                         if (item.getId() == itemId) {
45                                 item.increment();
46                                 return item.getCount();
47                         }
48                 }
49                 return 0;
50         }
51
52         public int getTotalCount() {
53                 int totalCount = 0;
54                 for (Item item : items) {
55                         totalCount+= item.getCount();
56                 }
57                 return totalCount;
58         }
59 }
참고: 소스 브라우저를 사용하면서 도움이 필요하다면, TracBrowser를 참고하십시오.