01: package org.drools;
02:
03: /*
04: * Copyright 2005 JBoss Inc
05: *
06: * Licensed under the Apache License, Version 2.0 (the "License");
07: * you may not use this file except in compliance with the License.
08: * You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing, software
13: * distributed under the License is distributed on an "AS IS" BASIS,
14: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15: * See the License for the specific language governing permissions and
16: * limitations under the License.
17: */
18:
19: import java.io.Serializable;
20: import java.util.ArrayList;
21: import java.util.Iterator;
22: import java.util.List;
23:
24: public class Cheesery implements Serializable {
25: /**
26: *
27: */
28: private static final long serialVersionUID = 400L;
29: public final static int MAKING_CHEESE = 0;
30: public final static int SELLING_CHEESE = 1;
31:
32: private final List cheeses = new ArrayList();
33:
34: private int status;
35: private int totalAmount;
36: private Maturity maturity;
37:
38: public List getCheeses() {
39: return this .cheeses;
40: }
41:
42: public void addCheese(final Cheese cheese) {
43: this .cheeses.add(cheese);
44: this .totalAmount += cheese.getPrice();
45: }
46:
47: public void removeCheese(final Cheese cheese) {
48: this .cheeses.remove(cheese);
49: this .totalAmount = 0;
50: for (Iterator it = this .cheeses.iterator(); it.hasNext();) {
51: this .totalAmount += ((Cheese) it.next()).getPrice();
52: }
53: }
54:
55: public void setStatus(final int status) {
56: this .status = status;
57: }
58:
59: public int getStatus() {
60: return this .status;
61: }
62:
63: public Maturity getMaturity() {
64: return this .maturity;
65: }
66:
67: public void setMaturity(final Maturity maturity) {
68: this .maturity = maturity;
69: }
70:
71: public int getTotalAmount() {
72: return this .totalAmount;
73: }
74:
75: public void setTotalAmount(final int totalAmount) {
76: this .totalAmount = totalAmount;
77: }
78:
79: public static class Maturity {
80: public static final Maturity YOUNG = new Maturity("young");
81: public static final Maturity OLD = new Maturity("old");
82:
83: private String age;
84:
85: public Maturity(final String age) {
86: this .age = age;
87: }
88:
89: public String toString() {
90: return "[Maturity age='" + this .age + "']";
91: }
92: }
93: }
|