-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathIntCell.java
More file actions
38 lines (33 loc) · 726 Bytes
/
IntCell.java
File metadata and controls
38 lines (33 loc) · 726 Bytes
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
package com.xp.java.dataalgorithms;
/**
* A class for simulating an integer memory cell.
* @author Mark A. Weiss
*/
public class IntCell
{
/**
* Construct the IntCell.
* Initial value is 0.
*/
public IntCell( )
{ this( 0 ); }
/**
* Construct the IntCell.
* @param initialValue the initial value.
*/
public IntCell( int initialValue )
{ storedValue = initialValue; }
/**
* Get the stored value.
* @return the stored value.
*/
public int read( )
{ return storedValue; }
/**
* Store a value
* @param x the number to store.
*/
public void write( int x )
{ storedValue = x; }
private int storedValue;
}