{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

351_midterm - CS 351 Programming III C Fall 2010 Mid-Term...

Info icon This preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CS 351, Programming III: C++ Fall 2010 Mid-Term Exam Date: 10/21/2010 Name: 1). (20 points) What will be printed out by the following code? for (int i=0; i<3; i++) { for (int j=G; j<9; j++) { switch (i) { case 0: break; case 1: continue; } Console::WriteLine(lO*i+j); if (j==4) { break; } else { continue; } } Answer: 0, 1, 2, 3, 4, 20, 21, 22, 23, 24. 2). (20 points) Assume the radius of the Circle defined below can be any integer. Write a code segment to go over the c ircles array, and if the radius of a circle is positive, draw the circle. Note that g— >DrawEllipse (Brushes : : Red, x , y, width, height) draws in red an ellipse bounded by the rectangle of size width x height and starting at (x,y). ref class Circle { public: int xc; // x coordinate of the center public: int yc; // y coordinate of the center public: int radius; }: Graphics Ag; ArrayList Acircles; Answer: for (int i=0; i<circleSK>Count; i++) { Circle Ap=(Circle)circles[i]; if (p—>radius>0) g—>DrawEllipse(Brushes::Red, p—>xc—p—>radius, p—>yc—p->radius, 2*p—>radius, 2*p—>radius); 3). (20 points) For each of the following Write statements, answer Yes or No to the question Whether the corresponding variable or member variable is accessible. (If you answer X out of 12 correctly, you earn 2*x—4 p-Oints.) ref class A { private: int aa; protected: int ab; public: int ac; }; ref class B: public A { private: int be; protected: int bb; public: int be; public: void bbb() { Console::Write(“{O}\n”, aa); // accessible? No Console::Write(“{O}\n”, ab); // accessible? Yes Console::Write(“{O}\n”, ac); // accessible? Yes Console::Write(“{O}\n”, ba); // accessible? Yes Console::Write(“{0}\n”, bb); // accessible? Yes Console::Write(“{O}\n”, bc); // accessible? Yes } }; \ ref class C { public: void ccc() { B Ab = gcnew B(); Console::Write(“{0}\n”, b~>aa);// accessible? No Console::Write{“{0}\n", b->ab);// accessible? No Console::Write(“{O}\n”, b->ac);// accessible? Yes Console::Write(“{O}\n”, b—>ba);// accessible? No Console::Write(“{O}\n”, b—>bb);// accessible? No Console::Write(“{O}\n”, b—>bc);// accessible? Yes } }; 4). (20 points) Usually a user can move an object by using the mouse to drag the object. What mouse events are generated when the user uses the mouse to drag the object? What event handlers need to be implemented to achieve the object movement? Answer: Events: mouse-glovvn, mouse-move(multiple), mouse—up. Events handler: F onn1_MouseDown, Form1_MouseMove and Forml_MouseUp. 5). (20 points) Describe the main difference between a modal dialog box and a modeless dialog box. If an application has a main application window and a modal dialog box, how can the modal dialog box be brought up and down? If there are some initial values to be sent from the main window to the modal dialog box, describe a way to accomplish this. Answer: The main difference: After a dialog box is bought up from the main window, a user is not able to interact with the main window if the dialog box is modal, and the user is still able to interact with the main window if the dialog box is modeless. The dialog box is bought up by calling the dialog box’s ShowDialogO, and it is brought down when a user clicks a button registered as .the AcceptButton or CancelButton of the dialog box. One way to send some initial values from the main window to the dialog box is through the constructor of the dialog box. ...
View Full Document

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern