This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds and have James Denton on-line!
See this thread for details.
Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Get/Set method  RSS feed

 
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Anybody?
 
Ranch Hand
Posts: 198
Java Linux Oracle
  • Mark post as helpful
  • send pies
  • 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 Java Oracle
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!