Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Java Expert


Home >> Java

You have been provided with a framework for a java application. It will not compile because there is a class and method missing (Visitor::visit). Your assignment is to create the visit method and whatever other methods you see fit. There are some rather unusual rules, though:

1) You may not use loops (while, for, do/until). Any looping that needs to happen must happen via recursion.

2) You may create ONLY local variables. You may NOT create members or globals.

3) You may NOT submit changes to any of the classes in the framework. You MAY and SHOULD, however, add your own tests to "Main" and test your code thoroughly.

4) Visitor must be a static class with only static methods. All methods except Visit must be private.

Visitor will be passed a "StatementsNode". Visitor must print assembly instructions in the following format:

##: opc op1,op2

For example:

0: add R0,R1

or

1: sub $1000,$2000

or

3: jmp $9999

The first value is a sequence number and is incremented after an instruction is printed.

There are two types of operand:

RegisterOperand - this represents a register in the CPU. It contains a single int. Print these as R# (R0, R1, R2, etc)

AddressOperand - this represents an address in the computer's memory. It contains a single long. Print these as $# ($1234, $3456), etc. Don't worry about forcing a certain number of decimal places.

Do not assume that if an instruction uses one type of operand, all of the operands will be of the same type. It is perfectly acceptable to have this:

add R0,$2000

There are three types of instruction node:

StatementsNode - this node contains a list of Nodes. Print each node in the list. The list will never be null or empty.

TwoOperandNode - this node represents math - add, sub, mul, div. Each node has two operands and a "type" character (one of +, -, *, /).

WhileOperand - this node represents a while loop. It contains two StatementsNodes - statements and conditions. Here is the format for a WhileOperand:

$X: <<>>

                bne $00000000

                <<>>

                jmp $X

X has to match the counter of the first instruction in the conditions. Neither statements nor conditions can be null or empty.

Attachment:- JAVA Assignment.zip

Java, Programming

  • Category:- Java
  • Reference No.:- M92224945

Have any Question?


Related Questions in Java

Assessment instructionsin this assessment you will design

Assessment Instructions In this assessment, you will design and code a simple Java application that defines a class, instantiate the class into a number of objects, and prints out the attributes of these objects in a spe ...

Chatbotscreate a small networked chat application that is

Chatbots Create a small, networked chat application that is populated by bots. Introduction On an old server park, filled with applications from the early days of the internet, a few servers still run one of the earliest ...

Simple order processing systemquestion given the classes

Simple Order Processing System Question: Given the classes Ship (with getter and setter), Speedboat, and SpeedboatTest. Answer the following questions: Refine the whole application (all classes) and create Abstract class ...

Solving 2nd degree equationsbull write the following java

Solving 2nd degree equations • Write the following Java methods • boolean real-sols(double a, double b, double c): it returns true if the 2nd degree equation ax2 + bx + c has real solutions • double solution1(double a, d ...

Part a specification - robot simulationpart a

PART A Specification - Robot Simulation PART A Requirements To complete this assignment you will use the supplied eclipse project Robot P1/. It is already set up to execute a simple arm movement loop which you will build ...

Operating systems assignment -problem 1 sharing the bridgea

Operating Systems Assignment - Problem 1: Sharing the Bridge A new single lane bridge is constructed to connect the North Island of New Zealand to the South Island of New Zealand. Farmers from each island use the bridge ...

Can someone please help me with the following java

can someone please help me with the following java question The input is an N by N matrix of nonnegative integers. Each individual row is a decreasing sequence from left to right. Each individual column is a decreasing s ...

Applied software engineering assignment 1 -learning

Applied Software Engineering Assignment 1 - Learning outcomes - 1. Understand the notion of software engineering and why it is important. 2. Analyse the risk factors associated with phases of the software development lif ...

Overviewyou are required to use java se 80 and javafx to

Overview You are required to use Java SE 8.0 and JavaFX to develop a Graphical User Interface (GUI) for the FlexiRent rental property management program created in Assignment 1. This assignment is designed to help you: 1 ...

Assignment - java program using array of objectsobjectives

Assignment - JAVA Program using array of objects Objectives - This assessment item relates to the course learning outcomes as stated in the Unit Profile. Details - For this assignment, you are required to develop a Menu ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As