Ola Krip

Greenhorn
+ Follow
since Nov 28, 2018
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
1
Given in last 30 days
1
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Ola Krip

Campbell Ritchie wrote:

Ola Krip wrote:LOL YOU TELLING ME MY CODE IS MESSED UP DID FIX IT.
I took the counters out form the paint method and it works.... thanks  . . .

In reverse order:-
  • 1: That's a pleasure
  • 2: I still don't understand how you are getting from counter = 2 to prices for tea.
  • 3: Please avoid ALL UPPER CASE WRITING, even when you are fixing code.



  • Okay. Thank you.
    I am concerned tho as you said why are they teaching us applets, now I'm worried that when I would ever try to get a programming/software development job I will be using outdated stuff! I didn't know applets are not used anymore. Hopefully my whole course is not like this...
    2 weeks ago
    LOL YOU TELLING ME MY CODE IS MESSED UP DID FIX IT.
    I took the counters out form the paint method and it works.... thanks







    2 weeks ago
    I added money symbols for clarification.
    The applet is meant to display how many time the listed products are chosen and show the total amount of money due.
    However my code does not calculate if the product is selected 1 times, it starts calculating the total at the 2nd item
    So if there is 5 waters chosen at $2 dollars each, it shows total as $8 - I am always $2 short
    2 weeks ago

    Campbell Ritchie wrote:I can't understand the design. You are adding one to the coffee counter if you click the coffee label? Surely you should push a coffee button. So, you push the coffee button and order one cup of coffee. That means coffee counter = 1 and counter = 1. Then you click for tea, and now coffee counter = 1 and tea counter = 1 and counter = 2. That is what I would expect. Then you have the option of clicking another drink, or finishing. You obviously have only small tables which will only accommodate five drinks, so you have to stop at five. Or maybe it is because you are charging $70 for a cup of coffee and nobody can afford more than five? Or are those numbers coordinates?
    I can't understand why you have those tests for counter in the paint() method. What's more, the paint() method is changing the counters. I think that looks wrong.



    How else would I count how many times a person chose the product, because the amount each item is chosen is meant to display at the end along with the total money due.
    2 weeks ago

    Ola Krip wrote:

    Campbell Ritchie wrote:I can't understand the design. You are adding one to the coffee counter if you click the coffee label? Surely you should push a coffee button. So, you push the coffee button and order one cup of coffee. That means coffee counter = 1 and counter = 1. Then you click for tea, and now coffee counter = 1 and tea counter = 1 and counter = 2. That is what I would expect. Then you have the option of clicking another drink, or finishing. You obviously have only small tables which will only accommodate five drinks, so you have to stop at five. Or maybe it is because you are charging $70 for a cup of coffee and nobody can afford more than five? Or are those numbers coordinates?
    I can't understand why you have those tests for counter in the paint() method. What's more, the paint() method is changing the counters. I think that looks wrong.



    The number are coordinates. We are not meant to have a button. We are meant to have 1 textfield to input the choice. We need to make a self defined total with a method. The code works, caluclates fine except it doesn't calculate if the product is just :1 ..



    The total calculates the money due. The money is either 2.00 dollar or 1.5
    2 weeks ago

    Campbell Ritchie wrote:I can't understand the design. You are adding one to the coffee counter if you click the coffee label? Surely you should push a coffee button. So, you push the coffee button and order one cup of coffee. That means coffee counter = 1 and counter = 1. Then you click for tea, and now coffee counter = 1 and tea counter = 1 and counter = 2. That is what I would expect. Then you have the option of clicking another drink, or finishing. You obviously have only small tables which will only accommodate five drinks, so you have to stop at five. Or maybe it is because you are charging $70 for a cup of coffee and nobody can afford more than five? Or are those numbers coordinates?
    I can't understand why you have those tests for counter in the paint() method. What's more, the paint() method is changing the counters. I think that looks wrong.



    The number are coordinates. We are not meant to have a button. We are meant to have 1 textfield to input the choice. We need to make a self defined total with a method. The code works, caluclates fine except it doesn't calculate if the product is just :1 ..
    2 weeks ago

    Campbell Ritchie wrote:

    Ola Krip wrote: . . . This part I don't understand how to implement.  . . .

    You need to design it before you can implement it. But you seem to have something working. Please show us it and let's see if we can't get some more marks for you.



    This will probably give a headache to people who actually know java but this is where I'm at. I have pretty much everything working somehow except for calculating the total. The total is always 1 item behind.  don't get it.  For example, if you have 1 Tea it shows the total as 0. And After the 2nd item input is when it start calculating. Its hard to explain but see the screenshots. I have it so it multiplies the counter by the product cost.. I can't figure this out.. See the screenshots of the applet running






    2 weeks ago
    I got it ,all good. thanks all
    2 weeks ago

    Campbell Ritchie wrote:

    Ola Krip wrote:. . . College assigment..  . . .

    In which case, why are they teaching applets?
    How are you going to get any actions to work? You have several labels with prices on, but can you add action listeners to them? Why have you made the class implement action listener? You might see that in many books, but I think it violates the principles of object‑orientation. It is also unnecessary since the introduction of λs in 2014.
    I don't understand how your count of items makes people select a different drink.

    I think you are going to have to go back to your design and decide what you are going to do. Write down on paper, without using any computing words, how you are going to count items.



    So basically I have 1 text field for the user to input the item he wants, and for example when he picks out water and tea he then wants to finish the program. So he pressed 5 to terminate. Upon pressing 5 its meant to show

    Water selected : 1
    Soup selected : 0
    Tea Selected : 1
    etc.

    This part I don't understand how to implement.
    I'll probably just have to continue researching and trying to figure it out then.
    Thanks
    2 weeks ago

    Campbell Ritchie wrote:Welcome to the Ranch

    Why are you writing applets? They are obsolete. As for a label or writing text onto a panel, that depends on what you are going to do with it.



    College assigment..

    This is my new code now
    I have to implement a counter so that it counts how many times each product is entered. Upon pressing 5, the program is meant to terminate and show how many items each product was entered.
    I have one textfield for the user input (per my lecturers request) and I don't know how to implement the counter so that I can display the results for each proudct at the end. I think my lecturer said we need 5 counters but I  cant grab my head around how to input that into the program. I need a while loop for every counter right?

    2 weeks ago

    Swastik Dey wrote:Single = sign is assignment operator



    OMG WTF I swear I tried it before but I've been messing around with this code for so long now that I probably  messed something up last time I tired it. Thank you omg I  feel so dumb!

    Can you advise me if the items like water, soup etc. should be as a label or gdrawstring?
    2 weeks ago
    Doing an assignment, its a vending machine that has 4 items and a message is meant to be displayed whenever each of the items in selected or the program terminated.
    It's melting my head, cant find anything about it on google.

    This is only the beginning of my code.

    1. I don't know if I should have the items showing in the applet as a label  or gdrawstring.
    2. I am trying to implement an if statement to display a gdrawstring if the statement is met. I just want to know I'm on the right track with the code. In this scenario upon pressing 5 the program is meant to terminate and display the total amount of the products. However I am unable to as " VendingMachine.java:51: error: incompatible types: int cannot be converted to boolean if(total = 5)"

    What is the correct way to implement this?






    2 weeks ago