Please bare with me here. I am new to
java ranch and I am not sure how to
word things.
I have a project that uses a translator and instruction class. My teacher corrected my classes (translation and instruction) to work the way she wants them too. I now have to create a virtual machine class that:
VirtualMachine should include the following basic functionality:
• Have instance data for
- A StackProcessor object
- Simulated memory object
• Use an Instruction collection created by the Translator
- Remove one Instruction at a time and cause it to be executed
- Use the StackProcessor to execute instructions of the appropriate operation codes
- Use a simulated implementation of memory to execute memory-related instructions
(STORE, RECALL, INPUT)
• Use console I/O
Here is my classes or Instruction and Translator
Here is how she suggest the Virtual Machine to look:
For example, your VirtualMachine class could look something like this:
public class VirtualMachine
{
private StackProcessor processor = new StackProcessor();
private [something to represent memory];
public void process (ArrayDeque<Instruction> instructions)
{
…
while (! instructions.isEmpty())
{
Instruction ins = instructions.remove();
while (ins.getOperationCode() != Instruction.OPCode.END)
{
switch (ins.getOperationCode())
{
case PUSH:
processor.push(ins.getValue());
break;
…
}
This is what I have so far for my Virtual Machine
What I am trying to figure out is where I am going wrong with Scanning for a file and then telling it what to do with the file.I think I am reading it but cant figure out how to read line by line for instructions. I AM STUCK