Valhalla Legends Forums Archive | Java Programming | need EXTREME help on a schedule program

AuthorMessageTime
vtran31
I’m trying to create a computer program for a science project that is due in a little less than 3 weeks.  The program is a schedule program that will be used by the school (hopefully).  So far, I’ve created a text file of classes, a text file of teachers, and a test file of students. Each one of these text files is read into the main method of a class (each text file is read into a different class) .  The end result is I have an ArrayList of classes, an ArrayList of teachers, and an ArrayList of students ( sucky progression of thought but the best I could do).
Right now I have two main hurdles. 
1)I need to find someway to access a variable created in main ().  The variable is the ArrayList of classes, named “all“, which another method, findSchoolClass() , of my class needs to use.  I can’t seem to be able to call main or pass a parameter from main() to the  method.  findSchoolClass() . Help?
2) I do not know how to make it so that the classes are more balanced (so that one History class does not have 10 students while another has 30 students).  This is the crux of my program and the purpose of my “science project”. but I am stumped on what math equation or computer algorithm I need to use to balance my school classes.  Does anyone have any sort of idea of what I can do?

3 weeks to see if all my time put into this amounted to anything.  Time to get lots of Java :-P
February 8, 2005, 5:19 AM
The-FooL
For the first one, a possibility is to make a static class with static variables.  Then your other classes can all access this static class(including your arraylist).

For the second, just assign one student at a time to a class, to the class with the least amount of people.
February 9, 2005, 10:24 PM
Myndfyr
[quote author=The-FooL link=topic=10471.msg99066#msg99066 date=1107987842]
For the first one, a possibility is to make a static class with static variables.  Then your other classes can all access this static class(including your arraylist).
[/quote]

That is hardly the most effective way to do it object-orientedly speaking.  You don't call main(), it is called from the command line when you type "java MyProgramClassThatHasAMethodCalledmain".  Generally you'll be dealing with a program loop within main -- perhaps a do...while(expr) type of statement, and then let your objects do the work?

This is the kind of project that needs planning.  Why are you using Java if you're not trying to use OOP?
February 15, 2005, 12:36 AM

Search