Here is a description of the content of the UW library that you might find usefu
ID: 665046 • Letter: H
Question
Here is a description of the content of the UW library that you might find useful.
Spring is here. This is the time to head for the ocean and have some fun sailing , watching the stars, and fishing. Unfortunately, this class doesn't incluce such a field trip! But we can still get a taste of the ocean by drawing an ocean scene with a Java program.
Overview
In this project, you will complete several classes to draw a picture in a graphics window. The purpose of this assignment is to give you experience writing classes in Java and using Eclipse.
To do
Download the four files Fish.java, OceanScene.java, SailBoat.java and Star.java and include them in a Eclipse project (as we did in class). Run the program by instantiating the class OceanScene. You should get a window that displays the sky and the ocean. There should be the beginning of the drawing of a star in upper left corner of the sky and another one in the middle of the sky. Notice that the two stars don't have the same size. Read through the code of OceanScene and Star. You will see that when MountainScene is instantiated, a graphics window is created. Then a Star object is created. As it is, the draw method of the Star class draws two lines in the graphics window. Make sure that you understand how this is happening within the code.
None of the classes given to you are complete. Your assignment is to complete the four classes and create a fith class so that an instance of OceanScene appears as a picture containing four different ocean elements. Here is a list of the requirements of the assignment :
Your picture should have 4 types of elements. 3 of them must be a sailboat, a fish, and a star. The fourth one is up to you.
Create a class for each type of element. The class should at least contain a constructor and a private draw method. Don't change the signature of the constructor. Keep it as
public ClassName(int x, int y, double scale, GWindow window)
to mean create an object of type ClassName at location (x,y) in the GWindow window with size given by the default size times scale (e.g. you can set the length of the fish by default to 20. Then a scale of 1.5 would draw a fish with a length of radius 20*1.5 = 30).
Don't do the drawing within the constructor. Instead call the private method draw. We will see the advantage of using a draw method in our next homework assignment. Read through the Star class. It contains code to give you a better idea of what to do.
Complete the class OceanScene to create a picture with all of the elements in a graphics window. In the picture, each type of element should appear several times at different locations with different sizes. Also, some of the fish should be facing left and and others right.
The graphics elements should show some complexity. A single oval is not a good drawing for a fish.
The program should be correctly documented (use the same format as in the sample (javadoc comments /** and */)).
To create the graphics elements, draw them first on a piece of graph paper. It will make it easy for you to locate each point of your drawing with respect to some reference point (x,y).
If you want to create your own colors, use the Color constructor. It reads Color(r,g,b) where r,g and b are integers between 0 and 255. The color is a mixture of red, green and blue as specified by r, g and b. For example
Good luck!
Here is a possible picture (shown with only three types of elements. You have to put in a fourth one as well).
Your program has to be your own.
This project need some files to do it. If anyone can help me to solve it, please send me a message. And I will send you the attachment. Thanks for helping. =]
Explanation / Answer
public class Ocean { public final static int EMPTY = 1; public final static int SHARK = 2; public final static int FISH = 3; public class Ocean { public final static int EMPTY = 1; public final static int SHARK = 2; public final static int FISH = 3;
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.