blob: 08a4724ca0536c116c4e9893a2756c389b377975 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
import java.io.Serializable;
import java.io.IOException;
/**
* This class represents an apple that has the following two attributes
* <UL>
* <LI>a variety (i.e. "Macintosh" or "Granny Smith")
* <LI>a brusing factor represnting how badly bruised the apple is
* </UL>
*
* @author Mik Kersten
* @version $Version$
*/
public class Apple implements Serializable
{
private String variety = null;
private int bruising = 0;
/**
* Default constructor.
*
* @param newVariety the type of variety for this apple
*/
public Apple( String newVariety )
{
variety = newVariety;
}
/**
* This inner class represents apple seeds.
*/
public class AppleSeed {
private int weight = 0;
private SeedContents seedContents = null;
/**
* This is how you get poison from the apple.
*/
public void getArsenic() {
System.out.println( ">> getting arsenic" );
}
/**
* Reperesents the contents of the seeds.
*/
public class SeedContents {
public String core = null;
public String shell = null;
}
}
/**
* Sets the bruising factor of the apple.
*
* @param bruiseFactor the new bruising factor
*/
public void bruise( int bruiseFactor )
{
bruising = bruising + bruiseFactor;
if ( bruising > 100 ) bruising = 100;
if ( bruising < 0 ) bruising = 0;
}
/**
* Returns the bruising factor.
*
* @return bruising the bruising factor associated with the apple
*/
public int getBruising()
{
return bruising;
}
/**
* Serializes the apple object.
*
* @param oos stream that the object is written to
*/
private void writeObject( java.io.ObjectOutputStream oos )
throws IOException
{
// TODO: implement
}
/**
* Reads in the apple object.
*
* @param ois stream that the object is read from
*/
private void readObject( java.io.ObjectInputStream ois )
throws IOException, ClassNotFoundException
{
// TODO: implement
}
}
/**
* Stub class to represent apple peeling.
*/
class ApplePealer
{
/**
* Stub for peeling the apple.
*/
public void peelApple() {
System.out.println( ">> peeling the apple..." );
}
}
|