• 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
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

java list with objects and methods

 
Ranch Hand
Posts: 87
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So im working on this website that teaches you and they use there own cmd line, but here is my problem.

The program lets the user print seats info on a plane and reserve seats. they want me to add a method to delete a reservation.

here is what i added.

here is the method it is calling in another file


the second file (class seats) does not have get functions only set functions. I deleted them and it didnt effect the program.

My question is how does the makeEmpty method know what seat to delete, if the method call in the first file does not pass any parameters to makeEmpty.

ps the list code if you need to see it is

 
Rancher
Posts: 3413
33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

delete a reservation.


Where does the code keep track of  the reservations?
I wouldn't think a seat was the same as a reservation.  The use of a seat is reserved and that info keep as a reservation.  The seat stays, reserved or not.  A property of a seat would be that it was reserved.
To delete a reservation would be to change the seat's reserved property.

The method would need a reference to the seat to be able to change its contents.
 
Sean Paulson
Ranch Hand
Posts: 87
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
heres the code
this is the first class SeatReservation


here is the second file Class Seat


the code does work but i dont understand this one part

input is
 
Norm Radder
Rancher
Posts: 3413
33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

i dont understand this one part  


Which lines of what source file are you asking about?
 
Sean Paulson
Ranch Hand
Posts: 87
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
80 in the first one and 15 in the second one, how does the method makeEmpty know what seat to make empty when the call in 80 on the first file does not pass a value
 
Norm Radder
Rancher
Posts: 3413
33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

how does the method makeEmpty know what seat to make empty


The makeEmpty() method is in the Seat class.  It changes the values for the one instance of the Seat class.
The code on line 80 uses a reference to an instance of the Seat class to call its makeEmpty() method.
Here's an expansion of line 80:
 
Sean Paulson
Ranch Hand
Posts: 87
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok i think i get it, i think im just over thinking it
 
passwords must contain 14 characters, a number, punctuation, a small bird, a bit of cheese and a tiny ad.
Enterprise-grade Excel API for Java
https://products.aspose.com/cells/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!