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
{ 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
JavaScript is an extremely powerful object-based (or prototype-based) language. It is not a full-blown OOP (Object-Oriented Programming) language, like Java, however it is an objec

Why do we call JavaScript an Object-based Language? In java language an JavaScript shares several similarities with object-oriented languages, and thus is known as an object-ba

how to write a program to assign value of variable age and print if person is major.

Want experienced GLSL programmer for Java project Project Description: I am preparing a small 3d game engine in Java, and I wanted to hire a GLSL programmer to help out with

var temp =14; var y = 2; temp document.write(temp);

We need an OpenGL - based visualisation of an OBJ-File that was created out of Maya3D. (important: we have to use OpenGL with Java - JOGL) In other words: we have an OBJ-file (a

Specifications 1. readNumberOfEntries → This function will ask the user for a value greater than or equal to two. The function will keep asking values as long as the user prov

Explain what is Naming Applets in java applets? You can give an applet a name by using the NAME attribute of the APPLET element. This allows communication between different app