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

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

--

  • svn:mime-type 속성이 text/plain (으)로 설정되어있습니다.
Line 
1 package net.okjsp.poll;
2
3 import java.util.ArrayList;
4
5 public class PollService {
6        
7         static ArrayList<Poll> list = new ArrayList<Poll>();
8  
9         public int add(Poll poll) {
10                 int newPollId = list.size();
11                 poll.setId(newPollId);
12                 list.add(poll);
13                 return poll.getId();
14         }
15
16         public ArrayList<Poll> getList() {
17                 return list;
18         }
19
20         public Poll get(int id) {
21                 for(Poll poll: list) {
22                         if (poll.getId() == id)
23                                 return poll;
24                 }
25                 return null;
26         }
27        
28         public int countUp(int pollId, int itemId) {
29                 Poll poll = get(pollId);
30                 return poll.increment(itemId);
31         }
32 }
참고: 소스 브라우저를 사용하면서 도움이 필요하다면, TracBrowser를 참고하십시오.