Question: Part B. Write a complete Java application that does the following in the indicated order. Refer to the String class API as needed. 1. Have

Part B. Write a complete Java application that does the following in the indicated order. Refer to

the String class API as needed.

1. Have the user input a String.

2. Output the following information in a single multi-line output box, with each value clearly

labeled:

a. the user-input String.

b. the length of the String.

c. the first character in the String.

d. the last character in the String.

Run the program twice with the following two inputs and submit your output along with your

source code file.

Run 1: string: RAIDERS

Run 2: string: ABC

Part C. Assume that the Vorpal class has the following API (only the method headers are

shown, not the method descriptions, and the method headers are in no particular order):

public Vorpal (int v)

public static void gimble ()

public Vorpal ()

public void snickSnack (char tulgey, int beamish)

public Vorpal (double tove, String uffish)

public char burble ()

Refer to the above to answer the following questions.

1. How many instance methods does the Vorpal class have?

2. What are the name(s) of the instance methods in the Vorpal class?

3. How many constructors does the Vorpal class have?

4. How many class methods does the Vorpal class have?

5. What are the name(s) of the class methods in the Vorpal class?

6. What is the return type of the burble method?

7. Write a Java statement (not a complete class or method) that creates a Vorpal object with

a tove of 2 and an uffish of Callay.

8. Write Java statement(s) (not a complete class or method) that invokes the snickSnack

method on the object you created in (7) with a beamish of 7 and a tulgey of X.

Part D. Begin by downloading ShapeDemo.java and all of the compiled .class files supplied

with Lecture 11 into a folder together. Compile and run ShapeDemo.java to see what it does.

Then read through the source code, trying to understand what is occurring. Refer as needed to the

class APIs for the Circle, Square, and Triangle classes.

Note on Java Graphics: The two-dimensional coordinate system used to position objects in Java

graphics has its origin in the upper left-hand corner of the window, so that increasing the ycoordinate

of a position results in moving the object down.

Now make the following changes to ShapeDemo.java. Test your program after each change.

1. Alter the comments at the top of the file to reflect your name, etc.

2. Instead of changing the color of the second square to blue, change it to black.

3. Create a third Square object and do the following with it:

a. Make it green.

b. Move it down 100 pixels.

c. Move it right (horizontal) 90 pixels.

d. Display it (make it visible).

4. Create a Circle object (after the Triangle is created). Do the following with this Circle

object:

a. Make it red.

b. Make it 50 pixels in diameter.

c. Display it (make it visible).

5. Immediately after the triangle object moves slowly across the screen (and before the

final pause) do the following: make the circle move slowly down the screen 75 pixels, and

then change the circle color to blue.

Take a screenshot of the final image your program produces (after all movement is

completed), and turn this image in along with your source code.

Part E. In this part you will write a complete Java application that uses Circle, Square, and

Triangle objects to draw a picture of a house with a sun and a tree, similar to the picture

provided below. The image your program produces must consist of the same shapes as this

picture, with the same colors, and with similar relative positions and sizes. However, do not

worry about matching the positions/sizes exactly.

Your program should pause at the end before exiting (as per ShapeDemo.java). Note the last

statement in the main method of ShapeDemo.java; you should put the same statement at the end

of your main method to avoid having to manually kill your program.

Once your program generates the correct image modify your code as follows: after pausing on

the completed image (but before exiting), make the sun move slowly downward until it

disappears.

Take a screenshot of the image your program produces (before the sun goes down), and turn this

image in along with your source code.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!