Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Brand New to Java!!! HELP

807599Mar 8 2007 — edited Mar 9 2007
Hi everyone,

Being this is my first post here I just want to introduce myself. My name is James, Im currently taking a beginning Java class online through my school. My first assignment is to make some alterations to some code, and Im hoping for some assistance. Ive read quite a bit about what the language, but the book Im using does a poor job of laying out the very basics of what to do.

This is the problem...

Modify class Gradebook as follows....

a. Include a second string instance variable that represents the name of the course's instructor.

b. Provide a set method to change the instructor's name and a get method to retrieve it.

c. Modify the constructor to specify two parameters - one for the course name, and one for the instructors name.

d. Modify method displayMessage such that it first outputs the welcome message and course name, then outputs "This course is presented by: "followed by the instructors name.

Now Ive actually read quite a bit and get most basic concepts except a few. This is the first question Ill ask for assistance on. There are two files with the original program, a .java file, and a .class file. The .java file is an editable text file, and it reads....

// Fig. 3.10: GradeBook.java
// GradeBook class with a constructor to initialize the course name.

public class GradeBook
{
private String courseName; // course name for this GradeBook

// constructor initializes courseName with String supplied as argument
public GradeBook( String name )
{
courseName = name; // initializes courseName
} // end constructor

// method to set the course name
public void setCourseName( String name )
{
courseName = name; // store the course name
} // end method setCourseName

// method to retrieve the course name
public String getCourseName()
{
return courseName;
} // end method getCourseName

// display a welcome message to the GradeBook user
public void displayMessage()
{
// this statement calls getCourseName to get the
// name of the course this GradeBook represents
System.out.printf( "Welcome to the grade book for\n%s!\n",
getCourseName() );
} // end method displayMessage

} // end class GradeBook


(please ignore incorrect spacing from left border)

the .class file however I dont believe is editable. The problem wants me to edit the class "Gradebook", does that mean make all alterations to the .java file? Or is there a way to edit the.class file?

Thanks for all your help in advance, I truly appreciate it.

James
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 6 2007
Added on Mar 8 2007
67 comments
464 views