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

This Month's Specials

Raging Tiger- Save $9.00
The Star and the Crescent- Save $9.00

   







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

Reply
 
Thread Tools Display Modes
  #1  
Old July 24th, 2009, 03:54 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

Quote:
Originally Posted by hEad View Post
God help me...
As I said, don't worry about it now

Your next step is to write the Enrollment class. It will have the three methods and a list of students. I recommend using a Vector for the list.

You can use the vector as so:

Vector students = new Vector();

then use the methods add() and remove() to add and remove students:

students.add(*student object*)
etc

That should be enough to get you started.
Reply With Quote
  #2  
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
  #3  
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:
  #4  
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
  #5  
Old July 23rd, 2009, 04:09 PM
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

Natpy is currently studying Java so he kindly agreed to do this exercise for you. After that I will check what he wrote and maybe correct errors if there're any.
All should be done by tomorrow evening.

Last edited by ano; July 23rd, 2009 at 04:26 PM..
Reply With Quote
  #6  
Old July 23rd, 2009, 04:25 PM
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

Quote:
the talent of game players never ceases to amaze me....
Nothing unusual in the fact that many programmers of different kinds like this game. Really.
Reply With Quote
  #7  
Old July 24th, 2009, 03:46 PM
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

Useless, of course. Kill it.
Reply With Quote
  #8  
Old July 24th, 2009, 10:53 PM
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

fook me Napty - a huge thanks for taking the time to have a look (and do) this - Im in your debt.

Looking over you work i realise how far i still need to go to understand programming. Time now to deconstruct what you have done and try to find out how it works...
Reply With Quote
  #9  
Old July 24th, 2009, 11:43 PM

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

Quote:
Originally Posted by hEad View Post
fook me Napty - a huge thanks for taking the time to have a look (and do) this - Im in your debt.

Looking over you work i realise how far i still need to go to understand programming. Time now to deconstruct what you have done and try to find out how it works...
Ah... if only I had been given such an opportunity when I was 8 and just starting to program in BASIC.

If deconstructing it and understanding it has a higher priority than just clearing the course, you're on the right track. Best of luck!
Reply With Quote
  #10  
Old July 25th, 2009, 05:07 AM

Calahan Calahan is offline
BANNED USER
 
Join Date: Nov 2007
Location: San Francisco, nr Wales
Posts: 1,539
Thanks: 226
Thanked 296 Times in 136 Posts
Calahan is on a distinguished road
Default Re: O.T Help sought from Java Programmers

Quote:
Originally Posted by Raiel View Post
If deconstructing it and understanding it has a higher priority than just clearing the course, you're on the right track. Best of luck!
: That's a good sentence for highlighting the problems with the current state of the entire pre-university educational system in the UK. Who cares if the students actually learn anything about what they are studying, just as long as they pass the course
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 01:07 AM.


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