Hello... I'm Kelechi Ngaka a computer scientist who makes things (code/food/designs), and welcome to my awesome blog powered by Blogger

Queue Model In Java

+
Mid semester, our lecturer Dr Mrs Oladeji asked students to develop a queue model as their individual project. This was on a Tuesday and I started gathering information, planning my strategies on how to tackle this project. Unluckily foe me, I was handicapped i.e. my laptop was faulty and this made things worse for me. 



After 2 days of rigorous analysis of the problem with my friend Joshua, we were informed on Friday that the lecturer changed her mind and asked students to do any model of their choice because she knew the task was challenging. This course I was offering in my third year was CSC 311, the course title was Operations Research and Techniques. At the end of the course, each student's expected to build a model from a range of models. These models are listed below:
  • Decision Tree Model
  • Forecasting Model
  • Network Path Analysis Model
  • Inventory Control System Model
  • Queue Model
  • Linear Programming Model

Now the ball was in my court either to continue the Queue Model, or to do another model instead. My friend Joshua left the model and started the forecasting model and told me "Why should I stress myself". I had already spent time breaking the problem into bits and already started programming (appox.. 10 lines). I gave it another shot by going to the cafe to browse for 2hrs straight looking for solutions, videos and facebooking too. But i did not get what i was looking for, depressed with the fact that i had no laptop. I still decided to do it.

A Queue model is an abstract representation of real life queues. In this model, a queue is meant to be animated and results are calculated with the use of queuing formulas, and are displayed for the user who has entered the arrival time and service time. This model is something that can be used by a novice i.e. easy to use and must be effective. The language to use were C++ or JAVA.. I chose JAVA, because i was being taught java at that moment in another course CSC 302.

My cross was that I had to finish this model before the end of the semester. I started sharing laptop with my room mate Joshua (each person was entitled to 4 hrs on the system). One day, he broke the rule and spent 6hrs because i was asleep, not ending there he was proving to me that it was his Lappy, so i got angry and went to use my class rep's laptop to program. I started, and in 2 days the first batch was finished i.e. Calculation with queuing formulas. It was done in a Java Frame, with exceptional GUI features like pics, buttons, labels e.t.c.

Time to kill (Goliath d' Animation), As i knew initially that this would take time, so I needed a constant laptop for programming, and my friend Kehinde came to my rescue by always giving me his Laptop both day and night. To animate in java, you need to be an applet master, but as for me i know how to go around stuffs, so i started reading e-books (3 java books at the same time i.e. Einstein) until i came across an applet program that moves a ball from left to right in a box. Then I copied the codes, implemented it and it was running, but that's not a queue model. Started reading over again to find out what each lines means, editing them until I was able to know how to move an element, stop elements and also print elements. These were the only things I used to build my queuing system, but if you see the codes, you will run.

My Queuing System 
models the FIFO structure (First In First Out)
It had one server
It had 4 different animations

1 - If Arrival time is greater than Service time 
A queue is formed, if more than one person in the system    

2 - If Arrival time is much greater than Service time                  
A very long queue is formed and balking occurs

3 -  If Arrival time is less than Service time
No queue is formed 

4 -  If Arrival time is equal to Service time
The queue cannot be modelled  please renter values because it would need other specifications.

All these features were in the program and it took me 4 weeks to finish it, but because i still had extra time, i edited the fonts, colours and helped my friends in their own models. Out of enthusiasm, i wanted to link my applet to the jframe but was unsuccessful because they could never be linked after seeking advice from Celestine and Osita. With my program ready, me and my friend Dotun, tested it and came across 3 errors (All typographical errors) and were corrected.

Finally the time of defence came, I entered her office and started defending my project, the lecturer liked it and told me that she would give me the project of one of the Prof's in the department to try and do it. A queuing model that has 2,3,4 servers and models time of arrival and departure of each customer too. I was shocked, but I stood my ground. After asking me questions on the project and answered correctly, my score was the highest mark.

In conclusion, the knowledge i gained doing this project was how to animate in java. Sometimes it's good to try something different and gain the experience because it would be useful in future.

Special thanks to my friends Joshua, Tayo, Patrick, Kehinde, Ben, Arinze that allowed me use their laptops, also thanks to Cj, Felix and Tunde for their motivational sessions, to Dotun for testing, to Celestine and Osita for their programming advices, to you for reading and to all science guys & girls cos I'm addicted to you.