Java programing help.

Discussion in 'School Work Help' started by an0nymous, May 14, 2008.

  1. an0nymous

    an0nymous Well-Known Member

    456
    53
    0
    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.
     
  2. yiubun

    yiubun Well-Known Member

    376
    53
    0
    ><.... 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?
     
  3. dim8sum

    dim8sum ♫♪♫♪♫♪♫♪♫♪♫♪....

    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
     
  4. ab289

    ab289 Well-Known Member

    3,452
    414
    280
    I did Java back in college; haven't done anything in it since. i'm guessing no help from me.
     
  5. w10_chi24

    w10_chi24 Well-Known Member

    607
    68
    0
    something like

    #include <stdio.h>
    main()
    int num1, num2, num3
     
  6. The_Jelly

    The_Jelly NSFW? :P

    Alot of my friends got screwed in uni when they did cs, all because our high school only offered VB.
     
  7. shiroe

    shiroe New Member

    2
    26
    0
    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.
     
  8. an0nymous

    an0nymous Well-Known Member

    456
    53
    0
    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
     
  9. yiubun

    yiubun Well-Known Member

    376
    53
    0
    I was just thinking of dropping programming!
     
  10. xaznxryux

    xaznxryux Well-Known Member

    2,723
    392
    468
    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
     
  11. ender

    ender Well-Known Member

    55
    31
    0
    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.
     
  12. Phil

    Phil 香港 PA 社團 揸Fap 人

    lol VB. net and Databasing !
     
  13. noonedoes

    noonedoes Member

    11
    26
    0
    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

     
  14. Hanz

    Hanz New Member

    1
    26
    0
    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.