File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes I Need to Write a Method Which Adds a Class Once Run Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "I Need to Write a Method Which Adds a Class Once Run" Watch "I Need to Write a Method Which Adds a Class Once Run" New topic
Author

I Need to Write a Method Which Adds a Class Once Run

Charlie McCabe
Greenhorn

Joined: Mar 24, 2005
Posts: 1
Hi, This may be simple to use guys but im stuck.

i am writing a booking class once i create a booking i can add and remove tickets to it. my problem is when i want to confirm this booking i need it to be able to add 2 classes (customer & payment) to it for the booking to complete.

This is so i have a customer and payment class assosiated to my booking.

/**
* completeBooking
* creates a new Booking
* @param customer
* @param payment
*/
public Booking completeBooking(Customer aCustomer, Payment aPayment) {

Booking booking = new Booking( aCustomer, aPayment);
booking.setTickets(tickets);

return booking;

}

This is what i had prviously but this was creating a new booking rather than updating the one i have already created. i realise now that instead of a

public Booking completeBooking(Customer aCustomer, Payment aPayment)
i should have a type void like
public void completeBooking(Customer aCustomer, Payment aPayment)

if this is rubbbish tell me! or point me in the right direction to write this method
Nick George
Ranch Hand

Joined: Apr 04, 2004
Posts: 815
That is not complete rubbish.


I assume this is a method of Booking. As such, you can directly access the member variables for customer and payment. Change them to the new value.


I've heard it takes forever to grow a woman from the ground
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

I'm not sure I understand your question, but I'll offer a couple of comments.

It appears that there is no need for this method to return anything, since you really want the side effects of what it "does." However, if you declare your Booking object within the method, its scope will be limited to that method. It seems to me that you'll want to access that Booking object outside of the method.


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: I Need to Write a Method Which Adds a Class Once Run