java applet assignment help, Programming Languages

Assignment Help:
Objectives: Create an applet, Use methods from the Graphics class , Use the Color class

General Instructions:
The java class that need to be imported into this assignment is below and it is called TrainApplet. Your jobs is to complete this class with the requirements below.
Create a new Eclipse project for this assignment and import the TrainApplet.java and train.html files into that project. Specification: Create an applet that has a train engine which moves across the window.
Complete the TrainApplet.java class by doing the following
Draw a train engine relative to a specific position so that the position of the train changes every time repaint is called. (The init method in the skeleton code that was provided sets up the animation for you. All you have to do is make sure the position changes each time the paint method is called.) Use several different methods from the Graphics class to draw the train. This means different shapes (rectangles, ovals, lines) as well as both fill and draw methods.
The position of the train should change by a small amount each time the paint method is called. When the train goes off one edge of the window, it should come back on the other edge.
Display some text in the applet window - a title, a quotation or whatever seems appropriate.
Add whatever else you want to the applet to make the picture interesting. The background should not be just the default color.
Use at least three colors in your applet. At least one of them should be a custom color. There are a number of sites on the web where you can find color samples with their RGB values.
Extra Credit (max +20)
Animate the wheels of your train engine.
Make your applet adjust appropriately when the window gets resized. For example, centered text should remain centered, the train should travel the entire width of the window, background graphics should adjust as needed.
Make the train follow a more complicated path.
Smooth out the wrapping - the train should not abruptly disappear when it reaches one side of the frame or abruptly reappear on the other side.
Documentation:

You should include javadoc comments describing the class in your code. Be sure to use the @author tag in the class comment.

You should include a plain text file called README (with no extension) that describes the overall design of your program and how to use it. See README.overview and README.example to get an idea of what is expected from your Project README files. Please also include your observations about the assignment and your experience with it.
Testing

After you upload your applet to onyx, run the applet using

appletviewer train.html

to make sure that it will run properly for the grader. Programs that will not compile or run receive an automatic zero score, so do not fail to test your program on onyx before submitting.
TrainApplet file:
/*
* TrainApplet.java
*
* COMPSCI125 Project 1: Train Applet
*/

importjava.awt.Color;
importjava.awt.Graphics;
importjava.awt.event.ActionEvent;
importjava.awt.event.ActionListener;
importjavax.swing.JApplet;
importjavax.swing.Timer;

/**
Animates a ____
@author your name
*/
public class TrainApplet extends JApplet {
//constant to regulate the frequency of Timer events
private final int DELAY = 500; //milliseconds
//variables for drawing / animating
privateint x, y;
privateint width, height;
privateintsquareSide;
privateintstepSize = 10;

/* This method draws on the applet''s Graphics context
*
* (non-Javadoc)
* @see java.awt.Container#paint(java.awt.Graphics)
*/
public void paint(Graphics canvas)
{
//let the JAppletdo its painting, first
super.paint(canvas);

int width = getWidth(); // applet width
int height = getHeight(); // applet height

//Fill the canvas with the background color
canvas.setColor(getBackground());
canvas.fillRect(0, 0, width, height);

//Calculate the new position
x = (x + stepSize) % width;

//Draw new square
canvas.setColor(Color.green);
canvas.fillRect(x, y, squareSide, squareSide);
}

/* Initialize necessary variables
* This method also sets up a Timer that will call
* paint() with frequency specified by the DELAY
* constant.
*
* (non-Javadoc)
* @see java.applet.Applet#init()
*/
public void init()
{
//Set square dimensions
squareSide = 50;
//Set the starting coordinates
x = 0;
y = getHeight()/2 - squareSide/2;

//DO NOT EDIT THE ActionListener / Timer CODE.
ActionListenertaskPerformer = new ActionListener() {
public void actionPerformed(ActionEventevt) {
repaint();
}
};
new Timer(DELAY, taskPerformer).start();
}
}

Related Discussions:- java applet assignment help

Identify the type of addressing, specify the function of the instruction an...

specify the function of the instruction and also specify whether its right or wrong-: (5) 1) MOV [BX],AX? Register Indirect addressing 2) MOV CX,[BX+DI]?Base plus index add

A Simple Distributed Computing Platform , You are asked to develop a replic...

You are asked to develop a replicator (client) that distributes a large job over a number of computers (a server group) on a single switched LAN (our BU04 lab). In this assignment,

Create a reservation system, Villa La Fourche Ltd is a small family busines...

Villa La Fourche Ltd is a small family business situated in the East Coast of Mauritius, more precisely Trou d'eau Douce.   The compound comprises of 6 independent villas, each of

Mvc architecture, MVC Architecture Model/view/controller (MVC) is a program...

MVC Architecture Model/view/controller (MVC) is a program structure, currently regarded an executive design used in program technological innovation. The design isolates "domain lo

Store an url in a dartabase, how to store an url in a dartabase(sql server ...

how to store an url in a dartabase(sql server 2005)? (or) create table b(url what is the datatype for url?

JUnit test, hi, can you help me with testing java classes I have wrote usin...

hi, can you help me with testing java classes I have wrote using java and jsp and servlet in eclipse ? I want to use JUnit for testing

Program to translate a sentence , a) Write a program i_language(Sentence,N...

a) Write a program i_language(Sentence,NewSentence) that translates a sentence to the i-language. In this language all vowels are changed to i and all other characters are kep

Artificial intelligence, Describe briefly how you might program a computer ...

Describe briefly how you might program a computer to exhibit fear or sorrow.

Genetic diseases, Genetic Diseases Problem Description Many human di...

Genetic Diseases Problem Description Many human diseases could be controlled by the knowledge of the gene's structure and pattern. The human gene could be represented by fou

Differentiate between high level and low level languages, The languages use...

The languages used in the module are of a type known as high-level languages. There is another set of languages known as low-level languages. (a) Differentiate between high-leve

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