/**
   COPYRIGHT (C) 2007 Jonathan Grothe
   All Rights Reserved
   Instances of this class represent main memory of a simulated computer.
   @author Jonathan Grothe
   @version 1.0 2009/2/2   
 */
public class Memory
{
	/**
	   Constructs a new Memory object with a capacity c. 
	   @param c = Capacity of this Memory.
	*/
	public Memory(int c)
	{	iMem = new int[c];
	}
	
	/**
	   Writes iVal at location iAd in Memory.
	   @param iAd = Location in which to store iVal
	   @param iVal = Integer to be stored at location iAd
	*/
	public void write(int iAd, int iVal)
	{	iMem[iAd] = iVal;
	}
	
	/**
	   Gets the value at location iAt of memory and returns it.
	   @param iAt = location of integer to be returned from memory.
	   @return value at iAt in memory.
	*/
	public int get(int iAt)
	{	return iMem[iAt];
	}
	
	
	/**
	   Outputs the value stored in each cell of memory.
	*/
	public void dump()
	{	System.out.println("Memmory");
		for(int x=0; x<iMem.length; x++)
			System.out.println("cell[" + Integer.toHexString(x) +"] =  " + Integer.toHexString(iMem[x]));
	}
	
	// Local variables
	private int[] iMem = new int[0];
}
