Computer Science II



Software Models and User Interfaces 10/16/14 (100 points)Name ___________KEY______________True/False on syntactic features of the C# language.[8 pts]__F___ C# has multiple inheritance like in C++.__ F ___ Exception handling is provided only by return values of function calls.__ T ___ Strings are immutable in C# like in Java.___ T __ Strings can be compared like numbers with < and == in C#.___ T __ C# uses a similar precedence rule system like Java and C.__ T ___ The verbatim string permits multiple lines in a quoted string.__ T ___ C# treats primitives (int, char, Boolean) like objects reducing the need for typecasting.__ T ___ C# will format the current time and date for you automatically to the local pattern.C# property definition and use in a class. [12 pts]Assume we have an instance variable called weight that stores weights consistently in English units of pounds. Fill in the property definition wtInLb for setting and getting the weight and then a second property wtInKg for setting nad getting the weight in kilograms. The wtInKg property cares for converting to Kgs to Lbs by multiplying by 2.2 on a set and dividing the weight by 2.2 on a get. Fill in the blanks for the wtInLb property. Then write the property definition for wtInKg.__public___ _double__ wtInLb { get { __return______ weight; } _set___ { _ weight ____ = value ; }}public double wtInKg { get { return weight / 2.2; } set { weight = value * 2.2; }}Show how to store 150 lbs. of weight in an instantiated object called person. person.wtInLb = 150;Show how to print the weight of the person object in kilograms using properties only?Console.WriteLine(person.wtInKg );More true/false on C#.[7 pts]__T__ The indexing operator [ ] can be overloaded, allowing string indexes.__ F __ Parameter passing is limited to call-by-value.__ T __ C# allows variable number of parameters with the params object [ ] parameter type.__ T __ ToString can take a format string as a parameter to control how the string is to appear.__ T _ A switch statement’s case clause can accept strings.__ T __ The tryparse method set reduces the need to use exception handling on numeric input.__ F __ Extensive use of exception handling is better design methodology than to use GUI widgets to control user inputSerialization of objects [5 pts]Why would we serialize an object?To save the object contents for full restoration later in another instance of the program.What must be true about the embedded objects of one that is serialized? They must be serializable as well.For each of the widgets below, designate its primary purpose, I=input or O=output. Choose the best one for its likely purpose even if it could be used for both.[8 pts]___I___Button___ O ___Label__ I ___TextBox___ O __ProgressBar ___ I ___RadioButton___ O __PictureBox___ I ___FileDialog___ I __DatePickerConsider the Input-Process-Output (IPO) versus Event Driven (ED) program models. We want to implement a simple survey system with two applications. One application permits end-users to respond to survey questions. The responses may be a choice from a set of restricted answers, a date , or entering a string or a number, some with decimal points. The questions and restricted answer options are held in a database. The responses are simply appended to a text file as received. The second application allows the organization to periodically produce statistical results of the survey responses printed in a well formatted report based on a simple input time period range.[10 pts]What would be your arguments for choosing an IPO model for the survey application?The synchronized pose a question, receive the response cycle is natural for the IPO model. Simple to transform to any type of interface: command line, or web form or app. The data saved is simple to append to the file.What would be your arguments for choosing an ED model for the survey application?Limits the responses to more likely correct answers, like a datepicker, or entry of legitimate numbers through widgets. Could more easily go back to previous questions and make changes to responses. Appearance of the questions may look nicer.5423535122237500Which model (IPO or ED) that would best implement the survey report. Give reasons for your choice.Because the input is limited to a date range and the processing is statistical, IPO is a natural solution. An event driven GUI is not providing any significant capabilities.119443520891500396049520891500243586013271500Draw a Data-Flow Diagram for the above system. Recall that input is shown as a , output is a , storage is and a process is . Connecting lines are labeled with data.[10 pts]33274007175500245173586995questions00questions1651635201295Format question0Format question16516351229995responsesresponses1423035111569515373355441951537335772795survey00survey2451735772795responses0responses2223135544195001194435122999500119443542989500210883586995003823335887095Stats calc00Stats calc43948351229995Stats summary0Stats summary4852035772795Date range0Date range3823335429895Response data00Response data43948351115695450913554419535947355441954166235157289500508063542989500332740035369500394652515875000Statecharts. [10 pts]To implement this statechart, you need __3___ (number) state variables. There are __8___ total states in this statechart. There are __4____ different events to be tracked.When in state 5, there are _3__ possible event transitions. Event ‘b’ is valid from these states:_______2,5,6,8___________________Explain the transition on ‘c’ from state 5:Enter state 7 but resume in state 1,2,3 depending on what it was when left on ‘d’Explain how the transition on ‘b’ from state 5 is different compared to ‘c’:Directly enter state 3 and 7 regardless of the history.Show [pseudo-]code for discerning what state transitions to make on event ‘b’ Make appropriate calls to goStateX() methods where X is the state number from the chart. You will need to assume existence of some state variables.[5 pts]if(mainState==8){ goState7(); goState3();} else if(mainState ==7 && state7var==2){ goState3();}Statecharts implement the controlling logic of an application. The application data model is separated out to different classes with access through public methods or properties. Explain where these calls to the model methods in the statechart would be made. [5 pts]In the goStateX() methodsExplain where the calls to the state transitions methods (in h.) are made.In the event handlers of the interface modulesShort answer.[5 pts each = 20 pts]Explain the purpose behind putting the data model in a separate class. What are we separating out? You may talk in terms of your game project this semester.You are separating out the input output processing which then can be a GUI or console or some other interface. Just the logic of the data modeling occurs in one place.When creating GUI application in Visual Studio using the drag and drop IDE for creating a form, you are not to edit a particular block of code in the forms class. Why?All of the properties (size, location, initial text values, etc) are set here and adjustable by the IDE. If you change the code, the IDE will overwrite it later or be confused!Give two significant uses of XML.Data transfer between disparate systems. Storage of dataset of varied complexity. Self-describing data. Separation of data from its rendering in a browser.List the 4 or more steps to connect a C# program to a database and ultimately use the result set of a query. You don’t need actual code but what information is coded in the C# objects and methods.Connect to the database with URL path, database, username, passwordSet up an adapter/access objectSet up queryCreate a command objectExecute queryProcess the result set locally ................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download