.com.unity Forums
  The Official e-Store of Shrapnel Games

This Month's Specials

Air Command 3.0- Save $12.00
War Plan Pacific- Save $7.00

   







Go Back   .com.unity Forums > Illwinter Game Design > Dominions 3: The Awakening

Reply
 
Thread Tools Display Modes
  #1  
Old July 23rd, 2009, 06:32 AM
hEad's Avatar

hEad hEad is offline
Sergeant
 
Join Date: Dec 2007
Location: WA, Australia
Posts: 228
Thanks: 18
Thanked 7 Times in 5 Posts
hEad is on a distinguished road
Default O.T Help sought from Java Programmers

I have, for all my sins, taken a Java programming unit as an elective. Now don't get me wrong, programming is something I have always wanted to have a go at - but with my current abilities, this particular assignment has ruptured my brain.


Design an application that simulates a University student administration system. The application should consist of three classes:

• Student
• Enrolment
• Admin

The Driver class should be the Admin class. All student objects must be stored in an array. Basic input validations need to be conducted. The details of the individual classes are as follows:

Student class (30 marks)
A student has a student number (8 digits, numbers only), first name (String), last name(String), gender (male or female)(String), date of birth (Gregorian Calendar), contact phone (10 digits) and the year (eg. 2009) they commenced the program (degree).

You should have get and set methods for all these data members. In addition to this, you must have a method printDetails() in the Student class.

Enrolment class (30 marks)
The Enrolment class needs to talk to the Student class. This class must have three methods, namely:

• addStudent()
• getStudent()
• printEnrolment()

Admin class (30 marks)

The Admin class should drive the system. It should have a method fillData() . This method should create an instance of enrolment, populate the enrolment with at least 5 students and finally print it. It should also have a method called searchStudent(). This method allows searching for a student based on user input. This user input is asked at runtime on the command line, no menu implementation is needed. This method is repeated until a student is found in the enrolment. If a student is found, the program will terminate.

Finally, all classes except the driver class must have a constructor.

This is what I have for Student so far...


public class Student {

public String studentID;
public String firstName;
public String lastName;
public String gender;
public String dateOfBirth;
public String phoneNumber;
public String yearCommenced;

public Student(String sId, String fn, String ln, String sex, String dOB, String pn, String yc){
sId = studentID;
fn = firstName;
ln = lastName;
sex = gender;
dOB = dateOfBirth;
pn = phoneNumber;
yc = yearCommenced;
}
public String getStudentID(){
return studentID;
}
public String getFirstName(){
return firstName;
}
public String getLastName(){
return lastName;
}
public String getGender(){
return gender;
}
public String getDateOfBirth(){
return dateOfBirth;
}
public String getPhoneNumber(){
return phoneNumber;
}
public String getYearCommenced(){
return yearCommenced;
}
public String printDetails(){
nothing here yet..
}

This represents a few days work - pitiful, i know, but i just can't get any momentum happening to solve the problem!

Basically i am at a loss. I sort of semi grasp OOB concepts but
trying to understand all the jargon and put this thing together
is giving me vertigo.

If any bright sparks out there have some knowledge on this and a bit of time to spare, I’d be mightily grateful.

Here are the assignment specs if you want a look.

Attached Files
File Type: pdf CPT121_2009_SP2_A2.pdf (27.4 KB, 440 views)
Reply With Quote
  #2  
Old July 23rd, 2009, 07:07 AM
ano's Avatar

ano ano is offline
Lieutenant Colonel
 
Join Date: May 2007
Posts: 1,462
Thanks: 34
Thanked 59 Times in 37 Posts
ano is on a distinguished road
Default Re: O.T Help sought from Java Programmers

What do you exactly want? Get this written or understand what you should do?

Regarding your piece of code: I wonder why your constructor assigns null values of your fields to parameters it receives.
Also, never leave fields public.
Reply With Quote
The Following User Says Thank You to ano For This Useful Post:
  #3  
Old July 23rd, 2009, 07:26 AM

Raiel Raiel is offline
Corporal
 
Join Date: May 2008
Posts: 149
Thanks: 49
Thanked 15 Times in 5 Posts
Raiel is on a distinguished road
Default Re: O.T Help sought from Java Programmers

First, don't get discouraged because that's all you've managed to come up with in a few days (unless it's due tomorrow). If you're just starting programming, expect it to be a sharper learning curve than that of a blind and deaf mute attempting to play Dominions 3. Then, when things start clicking together for you, you'll be pleasently surprised.

I second ano's question, though. We get the assignment and we get that you're having trouble with it, but it's not clear exactly what you're struggling with.

I should stress that while I did take a Java course several years ago, I haven't touched it since. Almost every line of code I write is C++. But I'll help where I can.
Reply With Quote
The Following User Says Thank You to Raiel For This Useful Post:
  #4  
Old July 23rd, 2009, 07:30 AM
ano's Avatar

ano ano is offline
Lieutenant Colonel
 
Join Date: May 2007
Posts: 1,462
Thanks: 34
Thanked 59 Times in 37 Posts
ano is on a distinguished road
Default Re: O.T Help sought from Java Programmers

There's no problem to write this, actually. If I have time in the evening, it will take about 15 mins. I'm just not sure that's what you want. Because it will give absolutely no knowledge and make you vulnerable to simplest questions.
Reply With Quote
  #5  
Old July 23rd, 2009, 08:08 AM
hEad's Avatar

hEad hEad is offline
Sergeant
 
Join Date: Dec 2007
Location: WA, Australia
Posts: 228
Thanks: 18
Thanked 7 Times in 5 Posts
hEad is on a distinguished road
Default Re: O.T Help sought from Java Programmers

Quote:
Originally Posted by ano View Post
There's no problem to write this, actually. If I have time in the evening, it will take about 15 mins. I'm just not sure that's what you want. Because it will give absolutely no knowledge and make you vulnerable to simplest questions.
Sorely tempted... The thing i find with code is when you have an example to follow it makes sence. You can trace through it - work it out. I feel at present that i have gone from making simple procedural style programs to this, and i have got lost along the way.

Quote:
Originally Posted by Psycho View Post
First, in the constructor you inverted your assignments - it should be studentID = sId, instead of sId = studentID, etc. Then, your fields should be private. You also need setters. And probably not everything should be a String, but that's less important.

In printDetails() you would use a StringBuilder class to combine all those Strings from fields into one String the method will return.

Enrollment would have one array of Student objects, addStudent() would add a new student to the array and return the index, getStudent() would use the index to retrieve the Student object, printEnrolment would iterate through the array and invoke printdetails on each student and write that to System.out. It would be useful to have a method to return the number of Students as well.

Admin would have the Main method in which he would call filData and then searchStudent in a loop until he gets a result. fillData creates an Enrollment object, then Student object whose data are hardcoded and inputs them into the enrollment using addStudent, then finally printsEnrollment. searchStudent takes a year, then calls getStudent for each Student, takes his year and if it matches prints his data to System.out; it returns true if successful, otherwise false.

Anyway, that's how I understood what you are expected to do. I know it's a total beginner level project, but I think it's very poorly composed.
Looking at this i get some tingling in the back of my head. Its like understanding wants to burst through damn it! This is helpful though almost makes sence!
Reply With Quote
  #6  
Old July 23rd, 2009, 08:26 AM

Psycho Psycho is offline
Captain
 
Join Date: Jan 2008
Posts: 913
Thanks: 21
Thanked 53 Times in 33 Posts
Psycho is on a distinguished road
Default Re: O.T Help sought from Java Programmers

Think of a Student class as of a structure that holds data about one student. Think of the Enrollment class as of an array of Students (an array that can print it's contents). Think of the Admin class as of your procedural program (the Main method) with helper functions where parts of code are localized (fillData and searchStudent).
Reply With Quote
  #7  
Old July 23rd, 2009, 07:32 AM

Psycho Psycho is offline
Captain
 
Join Date: Jan 2008
Posts: 913
Thanks: 21
Thanked 53 Times in 33 Posts
Psycho is on a distinguished road
Default Re: O.T Help sought from Java Programmers

First, in the constructor you inverted your assignments - it should be studentID = sId, instead of sId = studentID, etc. Then, your fields should be private. You also need setters. And probably not everything should be a String, but that's less important.

In printDetails() you would use a StringBuilder class to combine all those Strings from fields into one String the method will return.

Enrollment would have one array of Student objects, addStudent() would add a new student to the array and return the index, getStudent() would use the index to retrieve the Student object, printEnrolment would iterate through the array and invoke printdetails on each student and write that to System.out. It would be useful to have a method to return the number of Students as well.

Admin would have the Main method in which he would call filData and then searchStudent in a loop until he gets a result. fillData creates an Enrollment object, then Student object whose data are hardcoded and inputs them into the enrollment using addStudent, then finally printsEnrollment. searchStudent takes a year, then calls getStudent for each Student, takes his year and if it matches prints his data to System.out; it returns true if successful, otherwise false.

Anyway, that's how I understood what you are expected to do. I know it's a total beginner level project, but I think it's very poorly composed.
Reply With Quote
The Following User Says Thank You to Psycho For This Useful Post:
  #8  
Old July 24th, 2009, 03:05 AM
hEad's Avatar

hEad hEad is offline
Sergeant
 
Join Date: Dec 2007
Location: WA, Australia
Posts: 228
Thanks: 18
Thanked 7 Times in 5 Posts
hEad is on a distinguished road
Default Re: O.T Help sought from Java Programmers

I really want to that you all for your help. I am studying for my degree correspondence because I'm a small town country hick - up to this point I have found external studies suits me fine, but for this unit... someone on hand to converse with is certainly missed.

I have finished the student class (I think) taking onboard your suggestions - public to private, inversion of assignments etc. I know I should get onto the main(), but needed a small win for some confidence, so Student class needed completion.

I still don't know the why and what of get and set methods, but I believe this will become apparent when I start fiddling with the array.


public class Student {

private String studentID;
private String firstName;
private String lastName;
private String gender;
private String dateOfBirth;
private String phoneNumber;
private String yearCommenced;

//Constructor
public Student(String sId, String fn, String ln, String sex, String dOB, String pn, String yc){

studentID = sId;
firstName = fn;
lastName = ln;
gender = sex;
dateOfBirth = dOB;
phoneNumber = pn;
yearCommenced = yc;
}
//Get methods
public String getStudentID(){
return studentID;
}
public String getFirstName(){
return firstName;
}
public String getLastName(){
return lastName;
}
public String getGender(){
return gender;
}
public String getDateOfBirth(){
return dateOfBirth;
}
public String getPhoneNumber(){
return phoneNumber;
}
public String getYearCommenced(){
return yearCommenced;
}
//set methods for data fields

public void setStudentID(String sId){
studentID = sId;
}
public void setFirstName(String fn){
firstName = fn;
}
public void setLastName(String ln){
lastName = ln;
}
public void setGender(String sex){
gender = sex;
}
public void setDateOfBirth(String dOB){
dateOfBirth = dOB;
}
public void setPhoneNumber(String pn){
phoneNumber = pn;
}
public void setYearCommenced(String yc){
yearCommenced = yc;
}
}

In the ball park?
Reply With Quote
  #9  
Old July 24th, 2009, 03:25 AM

statttis statttis is offline
Sergeant
 
Join Date: Dec 2008
Posts: 200
Thanks: 10
Thanked 10 Times in 6 Posts
statttis is on a distinguished road
Default Re: O.T Help sought from Java Programmers

Your student class looks good.

Quote:
I still don't know the why and what of get and set methods, but I believe this will become apparent when I start fiddling with the array.
Unfortunately, it probably won't become apparent. The assignment you've been given is a terrible way to learn the "why" of OOP, since what you've been told to do is code a procedural style program using objects. But no need to worry about that now
Reply With Quote
  #10  
Old July 24th, 2009, 03:45 AM
hEad's Avatar

hEad hEad is offline
Sergeant
 
Join Date: Dec 2007
Location: WA, Australia
Posts: 228
Thanks: 18
Thanked 7 Times in 5 Posts
hEad is on a distinguished road
Default Re: O.T Help sought from Java Programmers

Quote:
Originally Posted by statttis View Post
Your student class looks good.

Quote:
I still don't know the why and what of get and set methods, but I believe this will become apparent when I start fiddling with the array.
Unfortunately, it probably won't become apparent. The assignment you've been given is a terrible way to learn the "why" of OOP, since what you've been told to do is code a procedural style program using objects. But no need to worry about that now
God help me...
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT -4. The time now is 01:31 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©1999 - 2025, Shrapnel Games, Inc. - All Rights Reserved.