KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > getahead > dwrdemo > gidemo > Corporations


1 /*
2  * Copyright 2005 Joe Walker
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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 JavaDoc;
19 import java.util.List JavaDoc;
20 import java.util.Random JavaDoc;
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     /**
29      * Create a set of random corporations
30      */

31     public Corporations()
32     {
33         corporations.add(new Corporation("AAPL", "Apple"));
34         corporations.add(new Corporation("AMZN", "Amazon"));
35         corporations.add(new Corporation("EBAY", "EBay"));
36         corporations.add(new Corporation("GOOG", "Google"));
37         corporations.add(new Corporation("IBM", "IBM"));
38         corporations.add(new Corporation("MSFT", "Microsoft"));
39         corporations.add(new Corporation("TIBX", "TIBCO"));
40         corporations.add(new Corporation("YHOO", "Yahoo"));
41     }
42
43     /**
44      * @return
45      */

46     public Corporation getNextChangedCorporation()
47     {
48         // Who's is gonna be
49
Corporation corporation = (Corporation) corporations.get(random.nextInt(corporations.size()));
50         corporation.change();
51
52         return corporation;
53     }
54
55     /**
56      * Used to generate random data
57      */

58     private Random JavaDoc random = new Random JavaDoc();
59
60     /**
61      * The corporations that we manage
62      */

63     private List JavaDoc corporations = new ArrayList JavaDoc();
64 }
65
Popular Tags