My superclass
public class NewComputer
{
// display the users new computer
private String NewComputer; // computer of this NewComputer
// constructor initializes myNewComputer with String argument
public NewComputer( String name ) // constructor name is class name
{
myNewComputer = name; // initializes myNewComputer
} // end constructor
// method to set newComputer
public void setNewComputer( String name )
{
myNewComputer = name; // store user computer
} // end method setNewComputer
// method to retrieve user computer
public String getNewComputer()
{
return myNewComputer;
} // end method getNewComputer
// display computer to end user
public void displayMessage()
{
// this statement calls getNewComputer to get the
// new computer this NewComputer represents
System.out.printf( " User new computer for\n%s!\n",
getNewComputer() );
} //end method displayMessage
My main class
public class GaylesComputer
{
//main method begins execution of Java application
public GaylesComputer( String[] args )
{
// create Scanner to obtain input from command window
Scanner input = new Scanner ( System.in );
{
// create a NewComputer object and assign it to myNewComputer
NewComputer myNewComputer = new myNewComputer();
myNewComputer.displayMessage( nameOfComputer ); // user input
//description of current computer
System.out.println( "Acer" );
System.out.println("Windows 7 Home Premium 64-bit" );
System.out.println();//outputs a blank line
System.out.println( "20 inch HD" );
System.out.println( "1TB Hard Drive" );
System.out.println();//outputs a blank line
System.out.println( "Intel Core i3 Processor 2120" );
//calling myNewComputer displayMessage method
//and pass nameOfComputer as an argument
}
}//end main method
} //end class GaylesComputer
I have errors on this my main class has 10 errors but my superclass has only one and therefore confused. Thanks for you help


LinkBack URL
About LinkBacks
Reply With Quote
Do you have any recommendations?