PV178 Programming for .NET Framework
Week 2
Homework #1 - Simple class
Assignment
- Write a public class
PV178.Homework1.Mutant
implementing the interfacePV178.Homework1.IMonster
Chyba: Odkazovaný objekt neexistuje nebo nemáte právo jej číst.
https://is.muni.cz/el/1433/jaro2010/PV178/um/other/IMonster.cs
Requirements:
- properties
NumberOfEyes
andNumberOfLegs
throw exceptions according to the comments in the interface - the method
CalculateLifeSpan()
of the classMutant
returns a a life span of the mutant according to the schema/algorithm:- eyeless and legless mutants live for 32 years
- one more eye means double the life span of a mutant
- one more leg means -20 years of life
- mutants don't live shorter than 1 year
- the method
Scream()
of the classMutant
outputs a string "Wrghoauhhhh!!!" toSystem.Console
- add an extra static read-only property
MutantsCount
to theMutant
class, which maintains the number of objects of the classMutant
(hint: don't forget to update counter in constructor and destructor)
Submitting
- Name the file
Mutant.cs
and upload it to the directory of your seminar group (link below) before the deadline. - Deadline: 23:59 14.3.2010
Chyba: Odkazovaný objekt neexistuje nebo nemáte právo jej číst.
https://is.muni.cz/el/1433/jaro2010/PV178/um/11706605/Seminar2.zip
Seminar
- everything is enclosed in classes (no functions, no global properties)
- all the types inherit from the
object
class - referential vs. value types
- class members visibility
- it is always better to write visibility modifiers explicitly
- properties (code snippet "prop"), attributes, fields
- enums, structs (the difference between structs and classes)
- naming conventions