PV178 Programming for .NET Framework

Week 2

Homework #1 - Simple class

Assignment

  • Write a public class PV178.Homework1.Mutant implementing the interface PV178.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 and NumberOfLegs throw exceptions according to the comments in the interface
  • the method CalculateLifeSpan() of the class Mutant returns a a life span of the mutant according to the schema/algorithm:
    1. eyeless and legless mutants live for 32 years
    2. one more eye means double the life span of a mutant
    3. one more leg means -20 years of life
    4. mutants don't live shorter than 1 year
  • the method Scream() of the class Mutant outputs a string "Wrghoauhhhh!!!" to System.Console
  • add an extra static read-only property MutantsCount to the Mutant class, which maintains the number of objects of the class Mutant (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