Re: Java Problems (Really Need Help!)
jacobfreakingharris@gmail.com writes:
import java.awt.*; // get the java "standard graphic" classes
import java.applet.Applet; // get the java "standard applet" classes
import java.awt.event.*; // get the java "standard event" classes
You're teacher seems to like to teach dated topics.
Applets and AWT are used rarely today, although this
still might make sense in special environments.
private Color color1; // declare color 1 (red)
private Color color2; // declare color 2 (blue)
private Color color3; // declare color 3 (green)
private Color color4; // declare color 4 (yellow)
private Color color5; // declare color 5 (pink)
The many fields might be a possible smell (called ?the God
class?) of a lack of structuring of this class. Also, the
names of the fields possibly still can be improved.
// make (instantiate) the new PetRock1
myPetRock1 = new petRockApplet1();
The above comment looks redundant, as many other comments.
/**
* The petRockApplet1() method constructs pet rock 1 with a given
* major axis, minor axis, and name. It also defines colors 1 & 2.
*/
public void petRockApplet1()
{
name1 = "Jacob Harris' Pet Rock 1";
majorAxis = 30;
Here, the comment contradicts the implementation. The major
axis is not ?given? (as in a parameter), but is 30.
public void petRockApplet2()
{
name2 = "Jacob Harris' Pet Rock 2";
length1 = 30;
The code has several repetitions (redundancies).
F:\PetRockApplet.java:50: error: cannot find symbol
myPetRock1 = new petRockApplet1();
^
symbol: class petRockApplet1
location: class PetRockApplet
You need to learn the basics first:
- What unqualified names can be used in a scope?
(local variables of enclosing blocks, fields of
enclosing classes and statically imported names
come to my mind right now.)
- What is the correspondance between the parameters
used in a method documentation or declaration and
the arguments used in a method invocation?