• 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
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

I need help to create methods

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I need help to create methods in displaying allRent of bicycle and how do i start creating methods  of returnrentedBikes?













Thanks alot
 
Ranch Hand
Posts: 530
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think you use a collection (typically List) to store bikes rented by a customer.
Then returning a bike to the store is simply removing that bike from the collection.
 
Marshal
Posts: 74354
334
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch

Start by writing down what those methods should do and work out which class they should be in. I can't tell that because I don't know how you designed your application. I don't think that simply removing them from a customer's list of bicycles will be sufficient, however.
What you have could be improved greatly. There is no need to call toString() in line 3; System.out.print calls toString() indirectly, and so does the + operator. Why are you only showing the List when it contains bicycles? A java.util.List can usually be printed directly, and if empty it simply displays “[]”.
Don't use multiple dot operators (line 5) if you can help it. The rents variable should have private access and the Customer class should have a method like hasRents().tt
 
Greenhorn
Posts: 28
Eclipse IDE Redhat Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How many bikes do you have in Inventory (Perhaps an ArrayList)?
Will you track customers?
What exactly do you want the application to do?
What is the input? What is the output?
I think it would be a good idea to figure out what you want. Sketch is out on paper. I have been following Mr. Ritchies example of writing what I want the application to accomplishment.
Best - Two Cent Steve
reply
    Bookmark Topic Watch Topic
  • New Topic