Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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?

Anybody looking for a graduate programmer (Midlands, England)?
Posted
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.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...