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

Small projects, i am doing java and want projects with solutions to practic...

i am doing java and want projects with solutions to practice more and more

What is a variable in java program, What is a variable in Java program? ...

What is a variable in Java program? It's a memory location. Memory location is given some name. Memory location is being assigned some value. Value may change o

Online Store Website, Project Requirements • Create your own online store ...

Project Requirements • Create your own online store Web site, selling products of your choice. • Create pages that allow you to search and buy available products, as well as add,

Demonstrate your ability to ability to use java data , Purpose Demonstr...

Purpose Demonstrate your ability to ability to use Java data and control structures. Draw with the aid of conditionals and loops. Background Thought A note on comments:

Converting strings to numeric primitive data types, Converting Strings to N...

Converting Strings to Numeric Primitive Data Types To convert a string which is containing digits to a primitive data type, wrapper classes can help. parseXxx method can be u

How does JVM do dynamic checking, How does JVm do dynamic checking The ...

How does JVm do dynamic checking The JVM also does "dynamic" checking at runtime for certain operations, like pointer and array access, to make sure they are touching only memo

Explain about the security aspect of java, Java has some bugs in its applet...

Java has some bugs in its applets. Java team stated that they have zero tolerance over security features and subsequent editions of Java are managing Bug free environment. Some of

Javaserver faces navigation model, What is JavaServer Faces navigation mode...

What is JavaServer Faces navigation model? Ans) A mechanism for describing the sequence in which pages in a JavaServer Faces application are shown.

Write the javascript code for the function sumoddnumbers, Write the JavaScr...

Write the JavaScript code for the Function SumOddNumbers(maxNumber) in which can add non-negative odd numbers up to maxNumber and return their sum. Java Script Code

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