Win a copy of Serverless Applications with Node.js this week in the NodeJS 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:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Ron McLeod
  • Tim Moores
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Vijitha Kumara

I need help to create methods  RSS feed

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • 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
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • 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: 63843
209
  • Mark post as helpful
  • send pies
  • 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 Java Redhat
  • Mark post as helpful
  • send pies
  • 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
 
And then we all jump out and yell "surprise! we got you this tiny ad!"
global solutions you can do at home or in your backyard
https://www.kickstarter.com/projects/paulwheaton/better-world-boo
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!