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
Object-to-Relational (O/R) mapping : There are various ways to persist data and the persistence layer is one of the most important layers in any application development. O/R ma

Write JavaScript code to convert the number 236.2363611111556 into currency format and JavaScript statement to show output? Var input_amt = 236.2363611111556 ; mid_data = input

the textbok is Introduction to Java™ Programming, Brief Version, Eighth Edition Week 8 Exercises Chapter 8 Programming Exercises from Pages 295 - 299. Do Exercise Problems 2,

Why the number of temporary workers is on the rise? Discuss main reasons? Temporary workers: Temporary workers are those workers that a company can hire to perform a certain ta

How to Implementing the Cloneable Interface The java.lang.Object class contains a clone() method which returns a bitwise copy of the current object. protected native Object cl

Explain DATA SECURITY Management issue? All data in the system is extremely critical to its operation, the security of the customer's personal data is most important. Most of t

what are all possible ways in java for user input and output

How to write a program that converts US dollars into Canadian dollars.The program let the user enter an amount in US dollars and display it equivalent value in Canadian dollars whe

I want somebody to help me to create a program in java that helps me to read data from usb logs in windows Project Description: I want a java program that helps me to detect

Authentication is basically an identification step. Functionality used for J2EE security: Principal : An entity that may be authenticated and identified. Principal n