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

This Month's Specials

Raging Tiger- Save $9.00
winSPMBT: Main Battle Tank- Save $5.00

   







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

Reply
 
Thread Tools Display Modes
  #1  
Old July 24th, 2009, 06:28 AM

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

Your student class is fine.

The get/set usefulness will appear when you change the implementation. For instance, gender can only be 'male' or'female'. So when someone wants to set or change the gender of a student, you can check in the setGender method that he's putting 'male' or 'female', and refuse to do anything, throw an error or react however you like if they try to say setGender( "42" ). IF you leave the data public, you can have all kinds of spurious values in your fields.

Quote:
I recommend using a Vector for the list.
Note the assignment says array. I'd go with a Vector (or List) too, because using a java array would be totally stupid in this context. I suppose "array" was ment as a general term and not the [] thing.
Reply With Quote
  #2  
Old July 24th, 2009, 07:10 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

Using the List or Vector beats the point of the existence of the Enrollment class in the first place. I am pretty sure the intent was to make him create his own Vector class (with the name Enrollment). It's really not a very good project.

For gender the best way is to create an enum if Java supports those. Or a couple of constants and make the field int.
Reply With Quote
  #3  
Old July 24th, 2009, 08:11 AM

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

Of course using a string for gender is not great. A boolean would do the job, or a class with two fixed instances and a private constructor rather than an enum. But then IRL you would store that info in a database anyway.
Hand-writing an array with proper memory management is just a pain and probably beyond the OP's skills right now, so he's better off using a List to begin with in my opinion. It's also a rather useless exercise in java. It's great in C, but in java it's just silly as you could copy-paste the Vecotr code if you wanted to anyway.
Reply With Quote
  #4  
Old July 24th, 2009, 02:40 PM
Natpy's Avatar

Natpy Natpy is offline
Corporal
 
Join Date: Jul 2007
Posts: 106
Thanks: 0
Thanked 2 Times in 2 Posts
Natpy is on a distinguished road
Link Re: O.T Help sought from Java Programmers

Here
Attached Files
File Type: rar Students.rar (1.9 KB, 110 views)
Reply With Quote
The Following User Says Thank You to Natpy For This Useful Post:
  #5  
Old July 24th, 2009, 03:45 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

My java may be rusty, but... what is the Enrolment enrolment line in the main for?
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 10:03 AM.


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