• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Get/Set method

 
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!




 
Scotty Steven
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Anybody?
 
Ranch Hand
Posts: 198
Oracle Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 81
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Scotty Steven
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic