Download this DLL File
and write a program that uses this library
(it contains definitions for Pie, IceCream, and Dessert).
Here is the code snippet from yesterday's demo for your reference
Dessert d = new Dessert(Pie.Apple, IceCream.Vanilla);
Console.WriteLine(d.getPie());
d.addTopping(IceCream.Strawberry);
d.addTopping(IceCream.Vanilla);
d.printDessert();
Dowload this DLL File .
It contains the definition for the a typical BankAccount class
(methods: deposit, withdraw and getBalance).
Using this library,
write a C# program that creates a single bank account
with an initial balance, and repeatedly carries
out deposit or withdraw transactions.
Use Console for input and output.
Pattern your program after this EXE
file.
Submit this exercise through
moodle .
April 27:
C# Project containing a BankAccount
defininition to be used in demonstrating classes in C#.
May 2:
Take Quiz # 4
Download this C# Project ,
compile and execute. Take note of the compiler warnings and
the program's output. Understand why the compiler made that
warning and why the output is as indicated.
You will make some revisions to this project.
Refer to slide set 8 (on inheritance) for discussions
on polymorphic methods and abstract classes.
Revise EmpClasses.cs so that you add the virtual
keyword for Employee's increase() method, and the override
keyword for Manager's and Secretary's increase() method.
Observe what happens with compilation and the program's output.
Make the Employee class abstract
and make its increase() method
abstract (Delete the method's body).
There will be a compiler error.
Fix Prog.cs so that it instead creates two Manager objects and
one Secretary object; the compiler error should disappear. Execute
the program and observe its output.
Create a new project in C#. Create a Shape interface with
an area() and circumference() method. Create Circle and Square
classes that implement that interface. In a separate .cs file,
create a class with a Main() method that has an array of 4 Shapes
that refer to two circles and two squares. Then, write a for loop
that prints out the circumeferences and areas of the four shapes.
For those who are rusty in geometry: the area and circumference of
a circle: 3.14*r*r and 3.14*r*2; the area and circumference of a
square: s*s and 4*s.
Wait for your instructor. He will arrive by 5:30. Be prepared
for another quiz on the above exercises.
May 4:
place this database
in a folder that you are familiar with
update the DB connection string to refer to thr right folder
make sure you add the references System, System.Data,
and System.XML before you compile the project
compile and execute the program
Answers to questions brought up today:
classes that implement interfaces don't need (must not)
include the override keyword for its method implementations,
but you need to if subclassing an abstract class
printing enum values using ToString("D") is the same as casting to int.
Download and execute the following
application with database ,
to give you an idea of what is expected of you
for this hands-on exam.
The database is an employment database with a
department (dept code,name,number of employees) table
and an employee (id, name, salary, dept) table.
The application allows you to edit and view department
information and view employees under a department.
You have the option to start with
this C# project
which already supports the edit operation (the database
has already been placed in the bin\Debug directory of the project).
The edit operation is not part of this hands-on exam.
Hands-on exam requirements:
there should be a button from the main form
that, when pressed, displays department information
(code and name)
in a separate form, given a department code.
The department code will come from a textbox
in the main form. (60 points)
another button from the main form will
display, in a separate form, a department name
and names of employees under the department.
(40 points)
Bonus: display full employee records (id,name,salary),
together with the name when displaying employee information.
Also, display the total number of employees.
(10 points)
Submit a zip file of the project and submit through
moodle
May 22
On Binding Sources and DataGridView objects:
Creating a binding data source
before creating a data grid view
may result in a confused data source reference,
so it is probably safer to establish
the data source as you create the data grid view.
The necessary adapter will be created in
the process as well.
To synchronize the database
with an updated dataset, call Update()
on the adapter object with the
dataset as a parameter.
Tip: to ensure you are
using the correct object variables,
consult the call to Fill() used
in the Form_Load method
to fill the dataset;
the update call should be similar.
(IMPORTANT) During data srouce creation,
make sure you choose "No" to the
question whether you want to include the
database in the project or not.
This is the reason why updates would seem
to not work--the database is copied
into the execution folder every time the
application executes.