OOA question

  • Thread starter Thread starter Stephen Cao
  • Start date Start date
S

Stephen Cao

Hi all:

I have a base class SurveyObject, and I derive two new classes
Question and Instruction.

I then create an
ArrayList<SurveyObject> soList = new ArrayList();
and add Instructions and Questions to the ArrayList.
Instruction i1 = new Instruction();
soList.Add(i1);
Question q1 = new Question();
soList.Add(q1);
Question q2 = new Question();
soList.Add(q2);

I have a form1 to handle Instructions and a form2 to handle Questions.

What is most elegant way to select the approrpriate form to display
the appropriate SurveyObject when I loop through the ArrayList of
SurveyObjects?

Thanks,
Stephen
 
The cleaner solution is to have separate collections for each form. Note: You
can't add multiple types to a generic arraylist, you can with a non-generic
arraylist though.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top