Activity 1.8.1.
Drag the definition from the left and drop it on the correct symbols on the right. Click the "Check Me" button to see if you are correct.
// Single line comment/* Multiline block of comments */
/** Java documentation comments */
// are used to mark the rest of the line as a comment in many programming languages. If the comment is going to be multiple lines, we use /* to start the comment and */ to end the comment./** */, called the documentation comment. Java has a cool tool called javadochttps://www.tutorialspoint.com/java/java_documentation.htmhttps://www.oracle.com/technetwork/java/javase/downloads/index.htmlhttp://docs.oracle.com/javase/7/docs/api/java/lang/String.html/**
* MyClass.java
* @author My Name
* @since Date
* This class keeps track of the max score.
*/
public class MyClass()
{
private int max = 10; // this keeps track of the max score
/* The print() method prints out the max */
public print()
{
System.out.println(max);
}
}
Math.sqrt(num) Java method, which we will learn later, will return a special value NaN which stands for “not a number” if num is negative. But since you can’t really do anything useful with NaN it’s better to think of sqrt as having a precondition that says it only works properly if given a positive argument. These are described as special cases in the API documentation, for example in https://docs.oracle.com/javase%2F8%2Fdocs%2Fapi%2F%2F/java/lang/Math.html#sqrt-doublehttps://docs.oracle.com/javase%2F8%2Fdocs%2Fapi%2F%2F/java/lang/Math.html#sqrt-doubleNaN. Can you fix the value of num so that it does not return NaN? What is the precondition for the Math.sqrt method?forward method’s precondition is that the amount of pixels forward should be between 0 and the width and height of the world. If it receives value out of this range, it sets pixels to the closest legal values that it can so that the turtle appears just at the edge of the world./**
* Method to move the turtle forward the given number of pixels
* @param pixels the number of pixels to walk forward in the heading direction
* Preconditions: parameters pixel is between 0 and
* the width and height of the world.
* Postconditions: the turtle is moved forward by pixels amount
* but stays within the width and height of the world.
*/
public void forward(int pixels)
{
/* code to move the turtle forward */
}
Turtle forward method below. Try to make the turtle go completely off screen by changing the number of pixels given to the forward method. What happens if you put in negative numbers? (If the code below does not work for you, you can copy the code into this replit.com linkhttps://replit.com/@BerylHoffman/Java-Swing-Turtlehttps://github.com/bhoffman0/csawesome2/tree/main/_sources/Unit1-Using-Objects-and-Methods/TurtleJavaSwingCode.zip

https://www.youtube.com/watch?v=TRcReyRYIMghttps://www.agilesparks.com/blog/wake-up-in-the-morning-game/https://creately.com/* */, which generates a block of comments, //, which generates a comment on one line, and /** */, which are Javadoc comments and are used to create API documentation. /** method to add extra-credit to the score **/
public double computeScore(double score, double extraCredit)
{
double totalScore = score + extraCredit;
return totalScore;
}
Which of the following preconditions are reasonable for the computeScore method?