[java] need EXTREME help on schedule program

Started by
1 comment, last by CaptainJester 19 years, 2 months ago
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
Advertisement
About your second hurdle: Could you balance it as you assign the students to the classes? I'll give an example using 3 periods of a History class. I don't know how you are keeping track of the periods, but I assume you have some way of accessing them in order. So, when you see that Student A is taking history, add that student to period 1. Student B is added to period 2, student C to period 3, student D to period 1 again, and so on. I don't think you need any fancy algorithm, just loop through the available periods.

If the number of periods available isn't known until you know how many students will take a class, this might work better: (Total number of students taking history) / (number of history periods available) = (Number of students per period). Then assign the resulting number of students to each period. 30 students / 3 periods = 10 students per period.
Don't do work in the main method. Create an instance of a class and delegate the work to the class.
"None of us learn in a vacuum; we all stand on the shoulders of giants such as Wirth and Knuth and thousands of others. Lend your shoulders to building the future!" - Michael Abrash[JavaGaming.org][The Java Tutorial][Slick][LWJGL][LWJGL Tutorials for NeHe][LWJGL Wiki][jMonkey Engine]

This topic is closed to new replies.

Advertisement