Cags Posted March 14, 2005 Posted March 14, 2005 I'm not sure how easy this is going to be to follow but... heres my problem. 1. User clicks button for new quiz 2. Application creates instance of Quiz class 3. The constructor of the Quiz class creates a wizard form (passing in itself so the wizard can change its properties) If the user clicks cancel on the wizard form I'd like to destroy the class so that the main application knows a quiz wasn't created. The way i'm currently doing it is to set a 'Cancel' property in the Quiz class, then back in the main form checking this property and setting the Quiz class = null if 'Cancel' = true. Has anybody got any suggestions of a better way of achieving this? Quote Anybody looking for a graduate programmer (Midlands, England)?
Tygur Posted March 15, 2005 Posted March 15, 2005 Why not have a static function in the Quiz class that returns the instance, as set up by the wizard. You can make the Quiz constructor private so no code outside of it can create it directly. If Cancel is clicked in the wizard, then your function can just return null. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.