If you already know how to program with objects you can demonstrate this
demonstrate this by creating the attached challenge
and discussing it with your teacher
discuss.
It is all about the concepts! Whether it looks pretty is NOT IMPORTANT to show whether you can program! What is important is whether you use classes, encapsulation, …
Create a project called DucksPondVan
with your own name behind it.
In that pond there are 26 ducks. A duck can be a female or male:
This is determined when you create the ‘‘object’’ for that duck,
so you create a constructor with the parameter of whether it’s a
female or male. Furthermore, I can ask a duck
(choose how) whether it is male or female.
The pond contains frogs. Objects are also created for these.
Create a class Stork
.
The stork gets a method called EatFrog
,
with at least the frog being eaten as a parameter.
Somewhere in your program you have to call this method.
Add things to make it logical. Don’t be satisfied too quickly, if you want to show that you are a master of OOP, you can make this an elaborate program!
Discuss your solution with your teacher: write down the feedback! Discuss with the teacher what you can best concentrate on.
Some ideas:
Create a Class-library (choose as project type when creating project) that contains the classes Frog, Stork … and the logic. Then 2 User Interfaces (e.g. a Console app and a WinForms app) using the classes from the class library.
I need to be able to ask a stork if it has eaten a specific frog.
A frog can have 3 genders: male, female or I-don’t-want-to-say.
Let a frog randomly change gender once in a while. The stork then only likes frogs that have the same gender as the stork.
Do not use string or int as gender, but a suitable type!
Make up your own features.