File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Class schedule Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Class schedule" Watch "Class schedule" New topic
Author

Class schedule

Angel Dobbs-Sciortino
Ranch Hand

Joined: Sep 10, 2003
Posts: 101
I have a project that my partner has asked me to make for her. She is in college, and she wants a program to help you create a schedule. She would like to be able to put in all the classes she is interested in and all the different times they are offered. Certain classes would be weighted so that they would be required to be on the schedule, while others she just wants if they fit into the schedule. I was thinking of using a database to store the tables of all the class times. I have a couple weeks to work on this before registration begins. Can anyone give me any idea how I would go about implementing this?
Angel
Joel McNary
Bartender

Joined: Aug 20, 2001
Posts: 1824

Well, the first thing that I do when starting a new project is define my data structure and my requirements. These two go hand-in-hand, and you should do them simultaneously.
So, from the requirements given, it sounds like you need a table in your database that contains the following information:
Class Name
Meeting Time
Meeting Days
Weighting
Now, define data types for your fields. I suggest String/VARCHAR for Class Name, java.sql.Time/TIME for Meeting Time, int/NUMERIC for Meetind Days, and int/NUMERIC for Weighting. Of course, you may just want to use a String/VARCHAR for Meeting Days, depending on how comforatble yhou are with manipulating bits
Next, determine the type of database. If you are on a Windows platform, for this I would actually suggest an Access database. Easy to work with, easy to distribute. Failing that, consider either MySQL or a Text/XML file. (The former is easier to work with, the latter easier to distribute).
Now, determine the type of user interface that you want to work with. A simple Swing application would probably be best, although you could do this as a command-line program, an applet, or a J2EE-based (Swing and/or EJB) web application. However, the latter is really over-architecting a program like this (unless you are looking for a proof-of-concept).
Once you have the ability to enter and edit data, then you can go in and add functionality (things like displaying a suggested schedule based on relative weights and class times and other parameters...)
Then test the application. Try to break it. Once you can't break it, you are ready to deploy/distribute for User acceptance testing (you may want to skip this part for an application of this size).
Finally, the application is ready to be used. Be prepared to support any problems that the user may find with the application.
----------------------
This may seems a little bit excessive for a "simple" application like this (and you may have only been interested in the first part of my answer ), but these are steps that you (or someone) should do for any application that you develop. If you do this for the small ones, then you will do it for the large ones.


Piscis Babelis est parvus, flavus, et hiridicus, et est probabiliter insolitissima raritas in toto mundo.
Angel Dobbs-Sciortino
Ranch Hand

Joined: Sep 10, 2003
Posts: 101
Thanks for the info, Joel. I had already thought of all the data structure and the requirements. My main problem is thinking of a way to go through all the data and finding the class schedules that work. Should I be able to just use for loops to come up with the schedules, or would something more complex be required?
Angel
Chris Shepherd
Ranch Hand

Joined: Jun 27, 2000
Posts: 286
Interesting. I am working on a side project that involves just this kind of logic, but for a totally different application.
My thoughts on your requirements:
If you force each class to have a unique weight, it would make things easier. Then you simply start with the highest weight, place it in the first available time slot, move to the next weight, place it, and so on and so forth until all classes have been either placed or dropped. Then you store that order somehow and go back to the beginning again and do it with the highest weighted class shifted to the second time slot it could occupy. Once you have cycled through all the time slots, start over again with the high weight in the first slot, but go and shift the second weight to an alternate slot. Lather. Rinse. Repeat.
this is going to take a fair amount of time just to code, and the amount of combinations is going to be staggering if you carry it all the way out to changes in the last weighted class schedules.
Why don't you just make your friend a week long calendar with all the hours shown where classes are offered. then cut out and color code little pieces of paper for each class at each timeslot. then sit her down and tell her she can't eat or go to the bathroom until she's come up with a preferred schedule and 2 alternates.
OK, I'm kidding... sort of.
The human mind often does a better job at stuff like this than a computer does, simply because the person knows lots of the combinations that are undesirable(8AM classes every day of the week.Bleh), whereas the computer does not. The computer may come up with the same final solution, but it may be buried 300 combinations down from the top and may never get seen or recognized. The amount of people time spent doing it manually will most likely be less than your time coding it to work right. If your friend can't decide which schedule is best, just tell her you are working on a thesis paper about social programming and have her pick classes out weighted hats, reciting If statement rules for each one picked, and filling in her schedule as the if statements are satisfied. It will be good for some laughs.
I'm rambling now, but my main point is this - Don't code it for a one shot deal like this. Its probably not worth your time. Take her out to lunch, get her started with lots of drinks...and then spring the calendar and the IF statements on her. She'll have it figured out before you finish desert.
Chris
[ November 17, 2003: Message edited by: Chris Shepherd ]
Angel Dobbs-Sciortino
Ranch Hand

Joined: Sep 10, 2003
Posts: 101
Actually, after thinking about it for a while, I decided this is the kind of thing a lot of students would want, not just my partner. I sure would have wanted something like this when I was in school. I think it might be worth trying to code it and offering to other students as well. It'll make for an interesting project.
Angel
Angel Dobbs-Sciortino
Ranch Hand

Joined: Sep 10, 2003
Posts: 101
I found an algorithm that uses discrete mathematics and generates all combinations of n elements, taken r at a time. I've decided to use a CourseGroup object to contain all the times offered for a class, a Course object for each class offered, and a CourseTime for each time in the Course object. Thanks for the help.
Angel
Chris Shepherd
Ranch Hand

Joined: Jun 27, 2000
Posts: 286
OK, sounds like you've got your structure set up. How are you keeping track of the actual class time in the CourseTime object? Can you show the algorythm so I can see what you are working with? How about a Schedule object with a single instance to act as your calendar. Think of it like indiscrete sockets that you plug in classes. again, I'm not sure how much the algorythm is doing for you and how much you have to do with the data it returns. how are you handling the differing class lengths? How are you measuing time? By the hour? half hour? minute? second? Are you going to allow for travel time between classes?
You don't have to answer all these here, just wanted to make sure you were thinking about them when you are writing your code.
Could you post that algorythm? Id like to see if it would fit my aplication. Mines not based on time, its based on area and straight line cuts.
I'm interested in your progress with this, so post here if you have any rgeat solutions or problems.
Thanks,
Chris
Angel Dobbs-Sciortino
Ranch Hand

Joined: Sep 10, 2003
Posts: 101
How are you keeping track of the actual class time in the CourseTime object? <snip> how are you handling the differing class lengths? How are you measuing time? By the hour? half hour? minute? second? Are you going to allow for travel time between classes?

I am storing two Calendar objects for each CourseTime, one each for the start and stop times. The HOUR and MINUTE are set, and the Course object has a boolean isConflict() method that determines whether the times of two Course objects overlap at all. It does not allow for time to get between classes, since I figured it would be better to leave it up to the student to decide which course schedule is preferred, whether the classes are far apart or there is a mad dash between them.
Could you post that algorythm? Id like to see if it would fit my aplication. Mines not based on time, its based on area and straight line cuts.

Here is the link to the java source code for the Combination Generator.
Angel
Chris Shepherd
Ranch Hand

Joined: Jun 27, 2000
Posts: 286
Thanks for the link.
I assume that you are basing all your Calendar objects on the same week right? How are you handling multiple class times for an individual class? Like a class meets 12-1 on mon/wed/frid. Seems like you would need a 2d array of calendar objects for each CourseTime. Or are you grouping CourseTimes in each course to indicate this? Then you'd have to keep a vector/arraylist of CourseTime arrays. It seems like you either need another intermediate object to group and check your CourseTimes effectively, or you need to expand your CourseTime to become that object and hold multiple time slots during the week.
Doing that, you would have to pull the isConflict() method down into the CourseTime object.
My next question is how do you intend to display the courses to the user? I bet you could make a pretty cool graphical display just using labels. You would probably need to use gridbaglayout inside 5 separate vertical panels(one for each day). You could make the panel respond to right clicks with a popupmenu containing all the legal classes remaining for the entire calendar. They select one and it places the time labels in all the panels where they are needed and it internally weeds out all the courses that get ruled out becuase of that class addition. That actually would make your weeding process alot less intensive because it would be a progressive thing instead of just springing the whole sorting/testing process on the program at once.
Hmm, this is turning into the program version of the colored pieces of paper I mentioned earlier. It will be way cooler tho, because you can ask the program to suggest a class schedule and then you can tweak it. I think this would be much more useful than just spitting out hundreds of posible course schedule options that the student most sift through or change by hand.
So now you have 2 projects... The GUI and the schedule generator. Man I wish I had more time free so I could help. This is the kind of GUI stuff I do all the time. Let me know if you have anything you need help figuring out.
Chris
Angel Dobbs-Sciortino
Ranch Hand

Joined: Sep 10, 2003
Posts: 101
I assume that you are basing all your Calendar objects on the same week right? How are you handling multiple class times for an individual class? Like a class meets 12-1 on mon/wed/frid. Seems like you would need a 2d array of calendar objects for each CourseTime. Or are you grouping CourseTimes in each course to indicate this? Then you'd have to keep a vector/arraylist of CourseTime arrays. It seems like you either need another intermediate object to group and check your CourseTimes effectively, or you need to expand your CourseTime to become that object and hold multiple time slots during the week.
Doing that, you would have to pull the isConflict() method down into the CourseTime object.

The CourseGroup object represents the course being offered (all the different times you can choose from). The course object represents the specific course you can register for (with only one set of times). The CourseTime object represents one class period. For example, with each object also containing what is lower in the hierarchy:

The Course object contains an ArrayList of CourseTimes. When boolean Course.isConflict(Course course2) is called, it iterates through the the ArrayList of both courses, checking for a conflict. It does this with several if/elses and checks if one coursetime is inside another (if they are of different lengths), if the first one ends after the other starts, if first one starts before the other ends, etc.
My next question is how do you intend to display the courses to the user?

I do plan on using a GUI, but I want to work on getting the schedule generator done first. This is a higher priority, since my first priority is to get a program that just works for my partner's class schedule.
They select one and it places the time labels in all the panels where they are needed and it internally weeds out all the courses that get ruled out becuase of that class addition. That actually would make your weeding process alot less intensive because it would be a progressive thing instead of just springing the whole sorting/testing process on the program at once. <snip> I think this would be much more useful than just spitting out hundreds of posible course schedule options that the student most sift through or change by hand.

This sounds like a good idea, but I think I might do that as an extra option. There are two reasons for there being more than one possible schedule offered. One is if a class is closed and they need a new schedule. The other is if they are interested in more classes than they can take, and they want to see the different combinations they could have. Also, it shouldn't give hundreds of possible course schedules, since the user would enter which courses should be considered for the schedule.
I have some plans for this program in the future. I live in a city with a large university that has about 40,000 students. The class offerings are online, including whether it is full or not, and I would like to put this program on a web page using servlets and jsp. First I would have to see how feasible it is to get the information into a database and poll it every so often.
Angel
Chris Shepherd
Ranch Hand

Joined: Jun 27, 2000
Posts: 286
cool, that sounds great. I'm an app guy, and I'v never done servlets or jsp, so I don't know how feasable that is, but it should be doable.
How are you going to have them enter the classes? Are you going to pre enter all the course data and just let them weight it or are they going to have to enter all the data themselves? Any chance of you getting access or a copy(by permission) of the course data direct from The university? That might save you and your users time entering the data. All you'd have to do is interpret it once and import it to your DB. then a user weights classes that they are interested in and anything unweighted gets ignored.
Angel Dobbs-Sciortino
Ranch Hand

Joined: Sep 10, 2003
Posts: 101
How are you going to have them enter the classes? Are you going to pre enter all the course data and just let them weight it or are they going to have to enter all the data themselves? Any chance of you getting access or a copy(by permission) of the course data direct from The university? That might save you and your users time entering the data. All you'd have to do is interpret it once and import it to your DB. then a user weights classes that they are interested in and anything unweighted gets ignored.

This first version will require it to be entered into the database manually, unless I can get it from the university. Actually, what you just said is what I meant when I said:
First I would have to see how feasible it is to get the information into a database and poll it every so often.

What I meant is that I need to see if I can get all the class info from the university webpage and have it imported into the database, and then check every so often to update any changes.
Angel
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Class schedule