object-oriented application development 7.5 ects applikationsutveckling... · object-oriented...
TRANSCRIPT
Object-Oriented Application Development 7.5 ECTS Ladokcode: C1OA1B V17-3 The exam is given to: IS, IMIT15 ExamCode: Date of exam: 24 March 2017 Time: 09.00-13.00 Means of assistance:
Total amount of points on exam: 50 Requirements for grading:
Additional information:
Next re-exam date: May 2017
The marking period is, for the most part, 15 working days, plus up to 5 working days for administration, otherwise it’s the following date: Important! Do not forget to write the ExamCode on each paper you hand in. Good Luck! Examiner: Petter Dessne Phone number: 433 47 15
Exam OOAD, #1, March 24, 2017
Max score: 50 points.
Grades:
A: 90 % +
B: 80 % +
C: 70 % +
D: 60 % +
E: 50 % +
Less than 50 % means you did not pass the exam.
If there is something you do not understand, then explain how you interpret the assignment and do
as much as you can. The programming assignments are rather big, and it’s okay (and also advisable)
to just work on parts of them if you don’t know how to complete them in full.
Here are some starting instructions, so that we know that the technology works:
1. Log in with your given login credentials before the exam starts.
2. Start Visual Studio.
3. Create a Windows Forms project in C#, and name it “Converter” (or something else –
I’ll find it!).
4. When you see the empty Windows Forms project appear, put away the computer
keyboard (you are not allowed to use the computer for the theory questions).
5. When you have handed in the replies to the theory questions you can start working on
the programming questions. Then you will not be able to change the replies to the theory
questions!
In other words: Theory first, then programming.
Observe that you shouldn’t log in with your normal username (s123456 or so) but with the login
credentials you are given (such as user name TEN123 and password 12345). In case there is a
technical problem, speak to the exam administrators and let them move you to another computer
before the exam starts.
Allowed material: Paper, pen/pencil, English/Swedish/Chinese dictionary plus the computer for the
programming assignment. You can solve several assignments on one sheet of paper if you wish.
Good luck!
Petter
Theory
Question 1. (5 p)
Briefly answer the following questions.
a) What color does the following code in hexadecimal notation result in? #06E10A (1p)
b) About how much in the decimal system is 237? Also write an explanation how this is calculated
(2p)
c) Fonts are divided into two groups. Below are examples of the two groups. What are they called?
(2p)
Question 2. (4 p)
c) In .NET: what is a DataTable, and what is it used for? Also write some code for how to use it, and
state what using; is related to a DataTable.
Question 3. (6 p)
You have worked with several kinds of object‐oriented based applications on this course – admin
systems, dynamic web sites, and games. In addition, you have seen other applications such as
graphics software and music software (see below).
What do all of these applications have in common? In light of what you have learned during the
course, how can OO‐based systems, that is systems having an “OO‐based software architecture”, be
of help when developing such software?
Question 4. (8 p)
During the work on your game, you needed to make changes to existing code and also create your
own logic code. The code below can be used to fire bullets in one direction (up), starting at position
(200, 200). How can this code be enhanced so that it can fire a bullet in any chosen direction, from
this position? Rewrite the code for both the provided code from the TrackKeyboard method and the
entire AddBullet method.
Also: what does the very first line from the TrackKeyboard code do? [if (counter % 10 == 0)]
From TrackKeyboard:
if (counter % 10 == 0) { if (Utilities.IdentifyKey(Key.Right)) //Fire to the right { AddBullet(200, 200); //incorrect now } if (Utilities.IdentifyKey(Key.Left)) //Fire to the left { AddBullet(200, 200); //incorrect now } if (Utilities.IdentifyKey(Key.Up)) //Fire upwards { AddBullet(200, 200); } if (Utilities.IdentifyKey(Key.Down)) //Fire downwards { AddBullet(200, 200); //incorrect now } }
The AddBullet method. (The positions and speed properties have been set separately so that you can
easier see what is what.):
int bulletCount = 0; /// <summary> /// Adds a bullet that fires upwards from the given position /// </summary> private void AddBullet(float posX, float posY) { string bulletname = "bullet_" + bulletCount; Body newBullet = new Body(bulletname, 15, 0, 0, true, Colors.DarkRed, 0, 0, 0, 0); newBullet.PosX = posX; newBullet.PosY = posY; newBullet.SpeedX = 0; newBullet.SpeedY = ‐5; AddBodyToGame(newBullet); bulletCount++; }
Question 5. (12 p)
The one page web site depicted below looks nice, but it does not make use of any server code (such
as PHP or ASP.NET). Imagine that you met with the people having running the horseback business,
and then giving them suggestions on how this web site could benefit from adding ASP.NET controls
and code‐behind code. How would you suggest that their web site should be improved
(functionally)?
The web site should probably have four pages or so, so decide what they would be and what content
they would have. You don’t have to write all the code for those pages, but I want a discussion on how
the ASP.NET controls should work for every page. Preferably, I’d like to see some ASP.NET code for
the controls of interest, perhaps together with a few lines of code‐behind code. You do not have to
create any admin pages for this assignment.
In other words, expand the web site shown here to three or four pages, propose the ASP.NET
controls that should be added (in the web forms or in a master file), and write the (approximate)
code for those controls and for whatever they might need to have in code behind.
Coding
Question 6. (15 p)
Today’s assignment is to create a WinForms project for something you are familiar with – student
grades.
You will only need to create a start form and the registration of grades, so no saving or displaying of
the grades. However, the inserted text/integers must be validated in a separate class, and both forms
should be inherited from a base form. Screen shots and the exact requirements are found below.
Start form:
A welcome form having a welcome text
The form only has one button (for now) – the button which leads to the registration form
frmStart should inherit from a base form.
Adding grade form:
A textbox in which the user enters the given name (such as “Petter”) of the student.
A textbox in which the user enters the family name (such as “Dessne”) of the student.
A textbox in which the user enters the exam score.
A combobox in which the user enters the course grade. The combobox should have the
following values: “Not set” / A / B / C / D / E / F (see image below). These values can be set in
Design mode if you wish.
A button that closes the window.
A button that should eventually insert the data in a database. For now, you will only do
validation (see below) and also reset the values of the textboxes and of the combobox in
case the data were correctly written.
Also add labels as seem reasonable.
No more action is needed, that is, you do NOT have to save the data to a class or the like.
Validation:
When the user clicks Register, you should check that all textboxes have been filled in. Before
the actual validation takes place, it’s a good idea to first cut off blank space using Trim().
You should also check that the score textbox contains an integer, at least 0 and at most 100.
The validation of string lengths and integer values should preferably be done as two methods
in a clsValidation class:
o Ideally, the integer checking method should be called together with a max value, so
that it can be used from other places in the system. In other words, this method
should check a certain string and see if it’s a value between zero and the max value
sent in.
o The string checking method should take the smallest and the highest allowed
numbers that a string can be. In this case, the names should be between 1 and 30
characters in length.
Also check that the combobox has a SelectedIndex higher than zero.
Automatic setting of combobox value
(If you feel that you are running out of time, then skip this feature, since it isn’t needed for the rest of
the application to work.)
When the user has entered the exam score, the combobox should be updated (in case the number in
the score textbox is validated okay). So:
if the score is 90 or higher, the combobox text should be set to A,
if it’s between 80 and 89 points, it should be set to B,
if it’s between 70 and 79 points, it should be set to C,
if it’s between 60 and 69 points, it should be set to D,
if it’s between 50 and 59 points, it should be set to E,
if the score is below 50 points, the combobox should be set to F.
In order to get this feature working, here are two tips:
1. Don’t use the TextChanged property of the score textbox, but the Leave property instead.
This code will fire when you click or tab away from the textbox.
2. In this part of the assignment, it might be easier to work with the SelectedIndex property of
the combobox than with the SelectedText property: if (val > 89) cmbGrade.SelectedIndex = 1;
rather than if (val > 89) cmbGrade.SelectedText = "A";
Other:
All forms should inherit from a base form (frmBase.cs or Baseform.cs).
All controls should be named in a good manner.
All methods should be suitably commented.
When I judge your work, there will of course be points for how well you have succeeded with
the above requirements, but also for the degree of usability (=ease of use of the system).
Note that the TabIndex property can make the system easier to use.
Note! If you run into trouble, then skip the requirement and do as much as you can!
Code hints:
Below you find snippets of code that you could easily have looked up on the Internet, and that
can be of use in your application. It’s up to you to use these lines of code or not in your application.
(The screenshots underneath the code are just provided as clarifying examples – use any layout you
want. The screen shots were made in Windows 10, and they will look a bit different in Windows 7.)
int val = 0; int.TryParse(str, out val); MessageBox.Show("Please fill in all fields.");