Considering the knowledge of the C# programming language, this project develops a simple application where the pillars of object-oriented programming are used.
It's checking everything we can reuse.
In the case of this project, this concept is applied in the "Character" class, where all the points that all characters have in common were gathered.
Character.cs: 📁
- public class Character.
Inheritance is a mechanism that allows features common to several classes to be factored on a class basis, or superclass. From a base of classes, other classes can be specified.
In this project the "Urchin", "Fox" and "Echidna" classes inherit attributes from the "Character" class. The attributes are:
- string Name = "";
- string Classification = "";
- int Age = 0;
- string Origin = "";
- List Skill = null.
Polymorphism is the principle by which classes can invoke methods that have the same identification but different behavior.
In this project "Urchin" class characters can only attack or attack with bonuses.
Urchin.cs: 📁
- public string Attack();
- public string Attack(int Bonus);
Encapsulation is a code design principle that guides us to hide the functionality and functioning of our code inside small units (usually methods and functions).
This is where the business rule usually remains.
In this project this concept is applied in several stages, one of which is the rule of the attack bonus of the "Echidna" class.
Echidna.cs: 📁
- {return this.Name + " attacked with SUPER attack " + Bonus;}
- else { return this.Name + " attacked with HYPER attack " + Bonus;}
The project's characters were inspired by the Sonic the Hedgehog franchise.
This is a study project proposed through the Digital Innovation One platform.