Class question for Class

I'm a dumb novice and have an assingment for school...

I have to write a program that stores, manipulates and print student info

I have to write 2 classes Student and Admisions. Student will have the fields I need and Admissions will manipulate the data.

Student must have the following fields - Name , Address, Date (as Classes) and ID (as a string variable identifing the student)

My question is if Student is supposed to be a class and also it's fields are to be classes, how do I write those classes(fields) under the class Student (are they supposed to be methods of the class student, is that what they mean?) Or do I just write other classes within the class Student ?

Can someone show me an example how Name should be written within Student ? (Name is to have fields FirstName and LastName)

Help!!!!!

[853 byte] By [java-jivea] at [2007-10-3 5:00:28]
# 1

> My question is if Student is supposed to be a class

> and also it's fields are to be classes, how do I

> write those classes(fields) under the class Student

public class Student {

private String name;

private Date date;

etc.

}

> (are they supposed to be methods of the class

> student, is that what they mean?)

No. The fields will be objects (well references to objects, actually). You might have get/set methods to access those fields, but the fields themselves are just variables of the appropriate type.

> Or do I just write

> other classes within the class Student ?

You don't define those classes inside Student. Student will use String, Date, and possibly other classes defined elsewhere--either in the core API, or by you. (Looks like just cor API here, but I didn't look that closely.)

jverda at 2007-7-14 23:05:59 > top of Java-index,Java Essentials,Java Programming...
# 2

The Student class will have the objects of those class as members.

public class Name {

private String firstName;

private String lastName;

public void setFirstName(String firstName) {

this.firstName = firstName;

}

public String getFirstName() {

return this.firstName;

}

public void setLastName(String lastName) {

this.lastName = lastName;

}

public String getLastName() {

return this.lastName;

}

}

public class Student {

private String id;

private Name name;

private Address address;

private Date date;

// Rest of the code...

}

There would be a similar class for address

aniseeda at 2007-7-14 23:05:59 > top of Java-index,Java Essentials,Java Programming...
# 3
Thanks for the expanation.
java-jivea at 2007-7-14 23:05:59 > top of Java-index,Java Essentials,Java Programming...
# 4
Way to break it down Aniseed, you are the man.Thank You !
java-jivea at 2007-7-14 23:05:59 > top of Java-index,Java Essentials,Java Programming...