wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes getFirstName from one class (set & get) to another class (Main Program) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "getFirstName from one class (set & get) to another class (Main Program)" Watch "getFirstName from one class (set & get) to another class (Main Program)" New topic
Author

getFirstName from one class (set & get) to another class (Main Program)

Ween Li
Greenhorn

Joined: Aug 30, 2010
Posts: 4
Hi there

i have student class & MainApp class

How do i get getFirstName() method that returns the first name of the student from user input from Student record instance in MainApp class which contains?

array of 8 Student objects:


S. Nitesh
Ranch Hand

Joined: Jan 15, 2010
Posts: 36
    
    1

I assume that you want to know the usage of getter methods..
You can call the getter methods like below..

this will print "Aaron Ang" on console.
Is that you want???
Raymond Tong
Ranch Hand

Joined: Aug 15, 2010
Posts: 230
    
    2

I guess you want to extract the First Name from the Full Name?
You may find the link below useful
String in Java
Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

I would advise you to create a getter/setter for both firstname and lastname. Because if the first or last name contains a space then you won't be able to separate them.


"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
Ween Li
Greenhorn

Joined: Aug 30, 2010
Posts: 4
Hi Nitesh

i'm suppose to create an array to store 8 students, user will need to input data 8 student data - name & gpa only
Each element reference to Student class.

it should print "Aaron" as the first name when e.g: "Aaron Carter" & calculate the average gpa is input.



Thanks
Raymond Tong
Ranch Hand

Joined: Aug 15, 2010
Posts: 230
    
    2

Ween Li wrote:Hi Nitesh

i'm suppose to create an array to store 8 students, user will need to input data 8 student data - name & gpa only
Each element reference to Student class.

it should print "Aaron" as the first name when e.g: "Aaron Carter" & calculate the average gpa is input.



Thanks

To extract the First Name from the Full Name, you can have a look on the Java String API.
To calculate the average GPA, it is just simple maths. You should have no problem. But If you do, post your code and we would help.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: getFirstName from one class (set & get) to another class (Main Program)
 
Similar Threads
Printing Method (inheritance and super method)
inheritance homework assignment - im stuck
BJO - 3 main feature of OOP
Drop and Add Students to Course
Copy objects from one array over to another