Complete the implementation of the class, JAVA Programming

Assignment Help:

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.


Related Discussions:- Complete the implementation of the class

Java identifiers, 1. Which of the following are not valid Java identifiers,...

1. Which of the following are not valid Java identifiers, and why? (a) wolVes (b) United(there is only one) (c) 87 (d) 5 3 (e) Real ale (f) isFound?by 2. A cla

What are the non-final functions in java object class?, The non-final funct...

The non-final functions are clone (), finalize (), toString (), equals () , hashCode () and. The other methods like wait (), getClass (), notifyAll (), notify () etc are final

What is the data normalization also define its goal, What is the Data Norma...

What is the Data Normalization? Also define its goal. Data normalization is to sort out complex data within easy form. It uses to simplify the complex information to form it mo

Statements and operators, Operator Functionality E x...

Operator Functionality E x ample/Explanation = Sets one value equal to another counter=0  Sets the counter to equivale

Boardcoloring , n this problem you are given a board in which some of the e...

n this problem you are given a board in which some of the elements are placed as shown in diagram below. Each element represents a color. Fill the other elements in the board, such

What are the usages of package in java? , It helps to resolve naming confli...

It helps to resolve naming conflicts when different packages have classes with the same names. This also helps you prepare files within your project. As define : java.io package d

Write down the class electricitysource, Question : (a) Explain the con...

Question : (a) Explain the concept of polymorphism when used in programs using suitable examples of your own. (b) (i) Distinguish between abstract methods and non-abstrac

How to use dispatchaction, To use the DispatchAction, follow these steps: ...

To use the DispatchAction, follow these steps: ? Make a class that extends DispatchAction (instead of Action) ? In a new class, add a method for each function you need to per

Defiine the term object, Defiine the term Object ? Object is a named co...

Defiine the term Object ? Object is a named collection of properties (data, state) & techniques (instructions, behavior). Mainly Objects are key to understanding object-oriente

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd