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

This Month's Specials

ATF: Armored Task Force- Save $8.00
War Plan Pacific- Save $8.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, 296 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, 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:
  #6  
Old July 23rd, 2009, 07:59 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 honestly don't know what i want... I am just - stuck!

Is this a hard assignment? I feel that i have turned it into some insurmountable monster.

I think my problem is i just don't have a handle on the jargon and as such, find it difficult to derive any lasting meaning because it all seems so abstract.

Thanks for having a look guys. I think i need to go away and consider some questions to ask. The rotten thing is due in this Sunday - and here is me thinking i would knock it over in a week pfff!
Reply With Quote
  #7  
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
  #8  
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
  #9  
Old July 23rd, 2009, 03:33 PM

LDiCesare LDiCesare is offline
Captain
 
Join Date: Apr 2004
Location: France
Posts: 820
Thanks: 4
Thanked 33 Times in 24 Posts
LDiCesare is on a distinguished road
Default Re: O.T Help sought from Java Programmers

Quote:
Originally Posted by hEad View Post
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.
OK here they tell you what to do, now you should wonder why they say that. They ask you to have get/set methods. Some people would call this ugly, but there's a reason why. Namely, these methods should be the only way of accessing the data... See below in commented code.

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

• addStudent()
• getStudent()
• printEnrolment()
That and nothing more I suppose.
Quote:
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.
Ok so driver class will have the main() method, whose body is explained in English in the last sentences.
Quote:
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;
NEVER EVER EVER use public data members.
They tell you to have set/get methods. So make these data private and the get/set methods public.
Why?
Because you may want to change the implementation of your Student class (typically you'll plug it to a different database). If you have public data members, you must rewrite the whole front-end, i.e. those who use the Student class.
Quote:
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;
}
As already noted, it's studentID = sId; You should at least feed your class to a compiler, it would tell you some of your errors such as this one. Compilers are actually there to help you write code that works. Some may even say they are jsut limited testing programs.
Quote:
public String getStudentID(){
return studentID;
}
That's good, but now you also need to be able to set the student id.

Try to get all the set methods, and make sure your class compiles.
I'll simplify your assignment a bit, as you've already been simplifying it yourself without noticing:
1) Correct the class so that it compiles (namely, put the data members on the good sign of the "=" in the constructor)
2) Make all those data members private
3) Create one setXXX method for each data member and getXXX method you have. You can jsut have all of them manipulate strings for the moment.
4) Compile the thing again.

Once you have that, your Student class will be rich enough that it's usable. There are lots of things missing, like checking whether gender is 'male' or 'female', etc. but don't worry about these. Those should be the last things you do.

Now it would be nice if you could have a program that did something.
Personnally I'd start doing the driver class, but the Enrolment class is not that hard to do.
Create an Enrolment.java file and write it:
They tell you all it must have: A constructor (you don't need any data member initialisation so it's quite straightforward) and 3 methods. Not 4, not 2, three. You have their names but the guy who wrote the assignment was nasty in writing parenthesis afterwards.
In the summary table, you can read for instance that getStudent() retrieves a student given its index in an array. So getStudent must actually return a student and have an arrya index as argument.
Something like this:

Student getStudent( WhateverAnArrayIndexTypeMAyBe index) {WriteSomeWeirdCode();return theGoodStuden;}

Now they're telling you to store students in an array, so that should give you clues about the data members of the class (remember data members should be private).

Now you may have written Student and Enrolment class, but you won't have any idea if they work so you should start your Admin class and write a main() method. The main is described in the assignment: It must create an Enrolment, then call fillData on it. Just create ONE student to begin with.
If you manage to do that and have it work, the rest of the main method will be easy to write. Stop there, compile and try to run the program, fix it until it stops crashing. It won't do anything visible, but if it doesn't crash, it's already a good step forward.
Next step is to tell the main() to print the students data on screen. Note printEnrolment prints stuff on the screen so you may want to call that method. Compile. Run. Fix until it no longer crashes and until it outputs the data you want on the command line.
If you get to that point, you will have advanced a lot. You'll then have to make sure
1) you can handle several students
2) you implement the searchStudent method
3) It prints what you want, no more, no less and not some other student, in answer to searchStudent
4) You can start making sure that genders are male/female, phone numbers are numbers and not made of 4 digits and other type-checks.

Next you'll want to call
Reply With Quote
The Following User Says Thank You to LDiCesare For This Useful Post:
  #10  
Old July 23rd, 2009, 03:51 PM

chrispedersen chrispedersen is offline
BANNED USER
 
Join Date: May 2004
Posts: 4,075
Thanks: 203
Thanked 121 Times in 91 Posts
chrispedersen is on a distinguished road
Default Re: O.T Help sought from Java Programmers

the talent of game players never ceases to amaze me....
Reply With Quote
Reply

Bookmarks


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 02:50 PM.


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