01: /*
02: * Copyright 2005 Joe Walker
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package org.getahead.dwrdemo.gidemo;
17:
18: import java.util.ArrayList;
19: import java.util.List;
20: import java.util.Random;
21:
22: /**
23: * A manager for a set of corporations
24: * @author Joe Walker [joe at getahead dot ltd dot uk]
25: */
26: public class Corporations {
27: /**
28: * Create a set of random corporations
29: */
30: public Corporations() {
31: corporations.add(new Corporation("BAYC", "Bay Corporation"));
32: corporations.add(new Corporation("VIRT", "Virtualis"));
33: corporations.add(new Corporation("MGSF", "Megasoft Co."));
34: corporations.add(new Corporation("MAXI", "Maximegalon Ind."));
35: corporations.add(new Corporation("RIGL", "Rigel Cybernetics"));
36: corporations.add(new Corporation("TRTR", "Tretrigintillion"));
37: corporations.add(new Corporation("CONC", "Concor PLC"));
38: corporations.add(new Corporation("HYPS", "Hypersoft"));
39: }
40:
41: /**
42: *
43: */
44: public List<Corporation> getCorporations() {
45: return corporations;
46: }
47:
48: /**
49: *
50: */
51: public Corporation getNextChangedCorporation() {
52: // Who's is gonna be
53: Corporation corporation = corporations.get(random
54: .nextInt(corporations.size()));
55: corporation.change();
56:
57: return corporation;
58: }
59:
60: /**
61: * Used to generate random data
62: */
63: private Random random = new Random();
64:
65: /**
66: * The corporations that we manage
67: */
68: private List<Corporation> corporations = new ArrayList<Corporation>();
69: }
|