[Logo]
Forums Register Login
Get/Set method
I am working my way through a text book, trying to self-teach during my spare time. One of the exercises has me setting up a class called Purchase, with get and set methods. It then wishes me to set up a method in that class called display, to display the stored info (I've blocked out the code starting on lines 30-34 of the second class where this should happen). In the second class, called CreatePurchase, I create the info to send to set methods, with loops and exception handling.

I am stuck on how to do the display part of the exercise. I am attaching code. HELP!




Anybody?
I didn't look deeply in your code but what I understand is that you want to show value of Purchase object and you want a Display method in Purchase Class.
you should declare a Display() method without any argument list like public void Display(). You can call this method from your CreatePurchase class with Purchase class object like onePurch.display();

Inside this method just place the System.out.print statement to print the values of the object like System.out.print("Value of invoice is: " +invNumber);

Hope this help.
You have created 2 purchase class objects , but you have not stored them any where. Try to retain the objects in a collection object. Then iterate the collection and get the purchase object and get the values from the object.

Regards
Santhosh
@Manoj Kumar Jain

This help got me close enough to soling my problem. I had some other logic errors to deal with as well as I was out of scope when I tried to execute.

Anyways, Thank you to those who answered.
Won't you be my neighbor? - Fred Rogers. tiny ad:
Thread Boost - a very different sort of advertising
https://coderanch.com/t/674455/Thread-Boost-feature


This thread has been viewed 1451 times.

All times above are in ranch (not your local) time.
The current ranch time is
Apr 24, 2018 01:07:50.