Hands On labs

1. Handling exceptions

Goal: understand excectin handling

Create a console application that reads an user input. Try to convert the input to Interger-type. Create try-catch-finally -exception handling.

2. Handling array Lotto

Goal: to learn create a console application, to use arrays 

Task: In Finnish Lotto there is 39 numbers, and seven (7) numbers are drawn at randomly. Create a console application that drawn seven numbers out of 39 and shows numbers in order in the console. Example: 1, 10, 20, 21, 37, 38, 39. As a matter of course same number cannot occur. An end user can select how many drawns will be made, by given it as an argument, if argument is not given, default is one (1). If more drawns is done, every drawn will be presented at own line.

Additional task: In Viking Lotto six (6) numbers are drawn from 48, in your national lotto is drawn 5 from 90 or like, create also possibility for that. An user can select which Lotto he will play.

3. Lotto in Windows

Goal: Learn to create a Windows application and how to use basic controls

Task: Create a Windows application for Lotto. There is a combobox where to select what Lotto to play, there are textboxes where to give how many drawns will be made and there is a control where to show drawns, of course there are needed buttons where to start playing.

4. Creating (more) methods

Goal: to learn to use methods: creating methods, passing data to methods, returning data from methods,

Background: the next step in coding is to divide your code into methods. Methods are members of classess that hold code and can be called to execute that code.

Task: Divide your class to suitable methods. There should be also a method that writes Lotto-drawns to text file. First line on the text line is for a round (week) and drawns will start from the second line. Add also a method that opens saved text file to application. 

Additional task: An user can select save as text file or XML-file.

Taking care of interaction in Windows forms

Goal: to understand interaction in Windows forms

Task: Take your Lotto-checker application and think what controls should be enabled and what disabled in any situation. Create functionality that takes care of controls so that an end user cannot push wrong buttons or he/she cannot enter wrong data to textboxes.

5 Reading data from XML-file

Goal: to learn read XML-files to a form.

Task: Create a program that reads data from a XML-file and writes it to a Windows form. Use this XML-file and read it to a form. Add textboxes where you write data. Add next and previous button where an user can go forward or backward in data.

Additional task: An user can look customers data in simple list where every customer's data is in own row.

6. Creating a class

Goal: to learn to create classes: creating fields, methods, properties, constructors and so 

Background: OOP Object Oriented Programming is what C# is all about. C# has several differences from all other object-oriented languages.

Task:  Create a Windows form where you can add new customers to a spesific XML file. We want to keep following data from our customers: customer id, first name, last name, company, occupation/work title, e-mail address. Create a class for customers. Think what properties and methods you need.

7. Very simple connection to a database

Background: ADO gives an opportunity to connect to databases. It is a premier buildin component in Microsoft world for database connection. Within ADO we can use OleDB-drivers for connection to a datacase. For connecting to an Access database there is Jet-drivers.

Prequisites: A student should know basics of databases and he/she should have somekind of idea what is ADO.

Goal: To understand how to get data easily from database

Task: We have a ready database. There is customer data in the Access database. Download the database here. The database is locating locally in a computer of an end user.  There are x tables in the database. In this task you should read data from a customer table. Create a Windows application that can read and show all customers listed in listbox. So a listbox is filled automatically with the name of customers when a Windows form is activated. Whe an end user selects a customer in the listbox, the application will show all data from the selected customer in text-boxes.

7. Simple connection to a database

Background: ADO gives an opportunity to connect to databases. It is a premier buildin component in Microsoft world for database connection.

Perequisites: A student should know basics of databases and he/she should have somekind of idea what is ADO.

Goal: To understand how to get data easily from database

Task: We have a ready database. There is customer data in the Access database. Download the database here. The database is locating locally in a computer of an end user.  There are x tables in the database. In this task you should read data from a customer table. Create a Windows application that can read and show all customers listed in listbox. So a listbox is filled automatically with the name of customers when a Windows form is activated. Whe an end user selects a customer in the listbox, the application will show all data from the selected customer in text-boxes.

Additional task 1: Add Next Button to the application form. If an end user clicks Next button, data of the next customer will be shown in the form. Also the name of the customer in the listbox will change.

Additional task 2: Add Previous Button to the application form. If an end user clicks Previous button, data of the previous customer will be shown in the form.

 

Back