Complete the implementation of the class, JAVA Programming

The class TurtleQTwo extends Turtle by adding one new method, plus, which is specified below. (All other features of TurtleQTwo are the same as for Turtle.)

method plus(n in Int) state change pre n ≥ 1.

post The marker state of the receiver is not changed. But the pen state becomes "on" and the diagram of the receiver is changed as follows:

Four spots are added, one n places to the right of the current marker position; one n places above the current marker position; one n places to the left of the current marker position; one n places below the current marker position.

If the receiver has pen state "on", then a spot, is also added to the diagram at the marker position of the receiver. ( T h i s is not added if the receiver h as pen state "off".) After execution of plus the pen s t a t e of the receiver is "on". Other features of the receiver are not changed.

For example, if plus(3) is applied to a turtle whose marker is at (5,5) and whose pen state is "off", then it will add the spots shown in Figure to the diagram (leaving the marker state; unchanged and the pen state "on")

2100_complete the implementation of the class.png

(a) Partial code for the implementation of the class

TurtleQTwo is given below. Class TurtleQTwo
{
this.plus calls plusTurtleQTwo
}
// (1)

// (2)
}

method plusTurtleQTwo(n)
{

Show how to complete the implementation of the class by giving code to be added at (1) and (2) above.

(b) This part of the question asks you to use the WorkPad to test your implementation of TurtleQTwo and its method plus.

Posted Date: 3/7/2013 1:57:34 AM | Location : United States







Related Discussions:- Complete the implementation of the class, Assignment Help, Ask Question on Complete the implementation of the class, Get Answer, Expert's Help, Complete the implementation of the class Discussions

Write discussion on Complete the implementation of the class
Your posts are moderated
Related Questions
Explain the Basic Applet Life Cycle ? 1. The browser reads the HTML page and seraches any tags. 2. The browser parses the tag to search the CODE and possibly CODEBASE att

Describe about Applet Security? The possibility of surfing the Net, wandering across a random page, playing an applet and catching a virus is a fear in which has scared several

What is spreadsheet? List any two jobs that it can do? A spreadsheet is a grid which organizes data within columns and rows. Spreadsheets form it simple to display information,

Write a program in Javascript that will read in an XML file. This file will contain details of devices maintained by the IT department of an organisation including an ID number, de

Vehicle Loan Application: Type                                         Web-based Application Role                                          Weblogic administrator + develop

how to write coding for money and currency

Instructions Modify the program so that the computer will generate moves for the ‘O' player (it must continue to accept user input for ‘X'). A simple way to do this is to use a

In RPC the method invoker waits for the method to finish implementation and return the control back to the invoker. Therefore it is completely synchronous in nature. Whereas in JMS

How to Begin a Variable Name with a Number? If you need to starts a variable name along with a digit, prefix the name you'd like to have (e.g. 8ball) along with an underscore,

Implement relationship using a java program. Assume each course has a course title, code, subject and number of credits while each student has a name, registration number, list of