i need to write up a simple thread program that services few customers and fuel up on 1 pump at a time. just needs some guide to how to start. like classes i need.
><.... I'm doing computer science for first yr uni... I've aced Assignment one, (i'm not bragging), passed Assignment 2, FAiled assignment 3, got 0 for assignment 4.... Classes... haha, I still duno what they are and what they do All I know is the "system.out.print" + if statements. Anyway, Good Luck on your work and dont fail like me... Where abouts Melbourne are you? around the city much?
i dont do java, but i have done programming in VS and Fortran the best thing is just to get a starters guide on Java and start programming with examples, get to know the general syntaxes and structure of how to program. the more you program, the better you will understand it but i cant go into specifics cause i dont really know what your project is and i dont know java
I am thinking you should make 2 classes, GasStation and GasPump. The GasStation will do all the calcs etc... GasPump will record how much gas is taken per customer, as well as record how much is left in that actual pump and its full capacity. Not sure if this helped in any way.
i was thinking. Customer Class Casher class gasStation Class gasPump Class bascially the customer goes up to the casher and pay and goes to the pump. 2nd customer pay and waits until customer 1 finish using the pump. and so on. customer fills up according to the order they paid. does them class look right? Uni is like that. its very easy at the start. then it just jumps to very hard or CBF to do it and gave up. Im in VU
i believe this is C++ in microsoft studio xD, but then again C++ and java are very similar but yeh, you can use these as your variables, and use print statements to store the values into a big loop then as for the output, idk i would draw out an outline code or pseudocode if i were you, so people can help you easily on your code i would A. Main Function B. Input Function C. Output Function then store B and C in A not useful but i tried -_-2
I think it would help if you define more specifically what is it that you need to accomplish. The main thing with any cs programming is to break it down into separate pieces.
I recommend reading these 2 links. http://www.javaworld.com/javaworld/jw-04-1996/jw-04-threads.html http://www.cs.clemson.edu/~cs428/resources/java/tutorial/JTThreads.html They will help you understand threads. Basically you need 3 classes, 1 as a pump class, one customer class, and one main class. You'll instantiate multiple customer classes. This scenario is a simplification of the dining philosophers problem, a classic multi-thread synch problem, -http://en.wikipedia.org/wiki/Dining_philosophers_problem But in your case the pump is the food, and the customers are the philosophers
i see that you are trying to make a program that handles concurrency. Read this up. http://tutorials.jenkov.com/java-concurrency/index.html basically there's two way of making this program, by writing your own semaphore method or the java synchronized method. of course the latter is easier rather than semaphore.