doug5289
- 12
- 0
Homework Statement
Why am I getting an error message "Cannot find symbol"
Color myColor = new Color(255, 200, 150);
doug5289 said:I am trying to fill a rectangle and no matter what I put it doesn't fill it up. Any idea's?
g.fillRect(10, 10, 80, 30);
Mark44 said:LOL! Great minds think alike.![]()
You should put [ code] and [ /code] tags (without leading spaces) around your code. I have done this below.doug5289 said:I am getting this error while compiling this: Any help would sure be welcomed. I am in my first year and never dreamed it could be this hard.
E:\RistDouglas_DoubleMyNumberTester.java:21: cannot find symbol
symbol : constructor RistDouglas_DoubleMyNumber(int)
location: class RistDouglas_DoubleMyNumber
aDoubleMyNumberObject = new RistDouglas_DoubleMyNumber(num);
^
doug5289 said:Code:public class LastNameFirstName_DoubleMyNumberTester { //Class Non-Accessor/Non-Mutator Method public static void main (String[] args) { //Method's Local Variables int num, doubleNum; int DoubleMyNumber,aDoubleMyNumberObject; //Method's Statements //Display the purpose of the program. System.out.println("This program will take a programmer-defined " + "number and double it."); System.out.println(); //Prints a blank line. //Initialize the number. num = 7; //Construct the object. aDoubleMyNumberObject = new RistDouglas_DoubleMyNumber(); //Double the number. RistDouglas_DoubleMyNumber.doubleIt(); //Get the result. doubleNum = aDoubleMyNumberObject.getNumber(); //Display results. System.out.println("The result of doubling the number " + doubleNum + " is " + num + "."); System.out.println(); //Prints a blank line.
public class LastNameFirstName_DoubleMyNumberTester
{
//Class Non-Accessor/Non-Mutator Method
public static void main (String[] args)
{
//Method's Local Variables
int num, doubleNum;
int DoubleMyNumber,aDoubleMyNumberObject;
//Method's Statements
//Display the purpose of the program.
System.out.println("This program will take a programmer-defined " +
"number and double it.");
System.out.println(); //Prints a blank line.
//Initialize the number.
num = 7;
//Construct the object.
aDoubleMyNumberObject = new RistDouglas_DoubleMyNumber();
//Double the number.
RistDouglas_DoubleMyNumber.doubleIt();
//Get the result.
doubleNum = aDoubleMyNumberObject.getNumber();
//Display results.
System.out.println("The result of doubling the number " + doubleNum +
" is " + num + ".");
System.out.println(); //Prints a blank line.
// Mark44: no more code was shown.
}
}
public class RistDouglas_DoubleMyNumber
{
//Instance Variables
private int num, myNumber;
//Instance Constructor
public RistDouglas_DoubleMyNumber()
{
this.num = myNumber;
}
//Instance Mutator Method
public void setDouble(int doubleIt)
{
this.myNumber = myNumber * 2;
}
//Instance Accessor Method
public int getNumber()
{
return this.num;
}
}
aDoubleMyNumberObject = new RistDouglas_DoubleMyNumber();
RistDouglas_DoubleMyNumber numberObject = new RistDouglas_DoubleMyNumber(num);
public class RistDouglas_DoubleMyNumber
{
//Instance Variables
private int num, myNumber;
//Instance Constructor
public RistDouglas_DoubleMyNumber()
{
this.num = myNumber;
}
//Instance Mutator Method
public void setDouble(int doubleIt)
{
this.myNumber = myNumber * 2;
}
//Instance Accessor Method
public int getNumber()
{
return this.num;
}
}