Jump to content

Are there Any Computer Science People here (java)


Guest Anonymous

Recommended Posts

Guest Anonymous

I am taking a first level computer science class as part of my certification requirements, anyways this class is killing me. I just have no understanding of JAVA whats so ever. Can anyone help me out with this? Thanks

\\Description

This animation is a simple game that involves several interacting objects. Type demo.hw2 to see how it works. Hit the go button to get it started. Now click the mouse in the animation area to accelerate the white rectangle (the tanker) in the direction you clicked. Click to the left, it should accelerate left. Click to the right, it should accelerate right. Move the tanker under the blue box (a tank full of water). When the left edge is under the middle of the tank, water will start draining out of the tank and into the tanker. Click to the right to move the tanker toward the little red box at the right edge just below the surface. When the tanker is completely above the red box, the water will drain out. Notice that there is a number in the upper left corner of the scene. It is initially 0 but increases as water is drained out of the tanker.

The object of this game is to get as much water from the tank to the drain as you can as fast as you can. If you stay under the tank too long, water will be drained but the tanker will not be able to hold it, so it will be lost. So try to fill the tanker as full as you can but not too full. The maximum amount of water you can move is 100.

Your program must do the same thing. You can use different colors for everything. Feel free to add other things to the scene, but do not modify or obscure the operation of the tank, tanker and drain. Don't worry about exact positioning of things - just get them sorta close.

The tank must be 100 wide and 101 high. The water in the tank must be 100 pixels high to start out. If it is draining into the tanker, it gets one pixel shorter on every call of the draw method.

The tanker must be 100 pixels wide and 40 high. If water is draining into it, the water increases in height by 1 pixel on every call of the draw method. Likewise if water is draining out of it, the water decreases in height by 1 pixel for every call to the draw method.

The tanker has an x-position and a velocity in the x direction (positive is right, negative is left). This is a property of the tanker and should be instance variables. On each call of the draw method, the x position has the x velocity added to it. Clicking the mouse has the following effects:

If the mouse is clicked left of the tanker, the x velocity is decreased by 1.

If the mouse is clicked right of the tanker, the x velocity is increased by 1.

The drain is 10x10 pixels. It increases the counter in the upper left of the scene on every call of the draw method if the tanker is above it and draining.

Requirements

You must follow these guidelines to recieve full credit on this assignment.

You must first draw a diagram of all the objects in the program, their instance variables (with values if known), and their relationships (i.e., references to each other). This picture, which must be drawn neatly, must be handed in during your lab session. For an example of the type of diagram you're suppose to draw look here. It is worth 10 points.

You will recieve 5 points if you put your name on the assignment and follow the guidelines specified on the style guidelines webpage.

You will recieve 10 points if you have attempted to write the code.

You will recieve 15 points if your code compiles.

You will recieve 5 points each if you define the following three classes:

Scene - set everything up, draw the background and starting area, and call the other draw methods.

Tank - keeps track of the amount of water, draws the tank and water.

Tanker - keeps track of its position, velocity, amount of water, responds to mouse clicks, and draws the tanker.

Drain - updates the counter at the top left of the scene.

Note that the code to do the behaviors indicated above must be in the classes indicated. You won't get the five points if they aren't.

You will recieve 5 points everything looks right to start out.

You will recieve 10 points if the tanker moves properly in response to mouse clicks.

You will recieve 10 points if the tank drains properly.

You will recieve 10 points if the tanker fills properly.

You will recieve 10 points if the tanker drains properly.

You will recieve 10 points if the drain properly records the amount of water drained.

Link to comment
Share on other sites

Guest Anonymous

i seemed to figure it out after great deal of difficulties, no I have absolutley no prior expierence with any programming. Its horrible for me, I am getting dominated. I had a 3.66 gpa in college and I am barely passing a first year course..... anyways I will be done soon enough with it.....

Link to comment
Share on other sites

The initial difficulty is the hardest part about programming...once you get the hang of things, you'll find how much faster these things will come to you. Just remember that the first step is to come up with formulas such that you can easily place boundaries on them (so that you can determine where everything is positioned using numbers). And once you get a functional formula, then all you need to do is transcribe it so that it fits your program. Everything that comes afterwards is basically a matter of syntax and calling the write commands to get it to work.

What program are you using to write the java? Usually there will be a help file that explains the syntax for everything (a really good help file will show you examples too). For the rest of your programming career, the help file will surely be your best friend 2.gif

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...