0% found this document useful (0 votes)
16 views

Codechum

C# programming

Uploaded by

Janze Moubis
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views

Codechum

C# programming

Uploaded by

Janze Moubis
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

using System;

using System.Reflection;
using System.Collections.Generic;

public class Hero


{
private string name;
private int level;
private int experience;
private double vitalityPoints;
private double evasivenessPoints;
private double spellPoints;
private double attackDamage;

public Hero(string name, double vitalityPoints, double evasivenessPoints,


double spellPoints)
{
this.name = name;
this.level = 1;
this.experience = 0;
this.vitalityPoints = vitalityPoints;
this.evasivenessPoints = evasivenessPoints;
this.spellPoints = spellPoints;
}

public virtual void LevelUp()


{
this.level += 1;
this.vitalityPoints += 1;
this.evasivenessPoints += 1;
this.spellPoints += 1;
}

public int Attack(int healthPoints)


{
int attacksNeeded = (int)(healthPoints / this.attackDamage);
this.experience += healthPoints;

if (this.experience > this.level * 1000)


{
int extraExp = this.experience - this.level * 1000;
this.LevelUp();
this.experience = extraExp;
}

return attacksNeeded;
}

public string GetName()


{
return name;
}

public void SetName(string name)


{
this.name = name;
}

public int GetLevel()


{
return level;
}

public void SetLevel(int level)


{
this.level = level;
}

public int GetExperience()


{
return experience;
}

public void SetExperience(int experience)


{
this.experience = experience;
}

public double GetVitalityPoints()


{
return vitalityPoints;
}

public void SetVitalityPoints(double vitalityPoints)


{
this.vitalityPoints = vitalityPoints;
}

public double GetEvasivenessPoints()


{
return evasivenessPoints;
}

public void SetEvasivenessPoints(double evasivenessPoints)


{
this.evasivenessPoints = evasivenessPoints;
}

public double GetSpellPoints()


{
return spellPoints;
}

public void SetSpellPoints(double spellPoints)


{
this.spellPoints = spellPoints;
}

public double GetAttackDamage()


{
return attackDamage;
}

public void SetAttackDamage(double attackDamage)


{
this.attackDamage = attackDamage;
}
}
public class Brute : Hero
{
public Brute(double vitalityPoints, double evasivenessPoints, double
spellPoints) : base("Brute", vitalityPoints, evasivenessPoints, spellPoints)
{
SetAttackDamage(GetLevel() * GetVitalityPoints() + 500);
}

public override void LevelUp()


{
SetLevel(GetLevel() + 1);
SetVitalityPoints(GetVitalityPoints() + 5);
SetEvasivenessPoints(GetEvasivenessPoints() + 0.5);
SetSpellPoints(GetSpellPoints() + 0.5);
SetAttackDamage(GetLevel() * GetVitalityPoints() + 500);
}
}
public class Champion : Hero
{

public Champion(double vitalityPoints, double evasivenessPoints, double


spellPoints) : base("Champion", vitalityPoints, evasivenessPoints, spellPoints)
{
SetAttackDamage(GetLevel() * GetEvasivenessPoints() * 2 * (GetSpellPoints()
+ GetVitalityPoints()));
}

public override void LevelUp()


{
SetLevel(GetLevel() + 1);
SetVitalityPoints(GetVitalityPoints() + 2);
SetEvasivenessPoints(GetEvasivenessPoints() + 3.5);
SetSpellPoints(GetSpellPoints() + 1);
SetAttackDamage(GetLevel() * GetEvasivenessPoints() * 2 * (GetSpellPoints()
+ GetVitalityPoints()));
}
}
public class Magus : Hero
{

public Magus(double vitalityPoints, double evasivenessPoints, double


spellPoints) : base("Magus", vitalityPoints, evasivenessPoints, spellPoints)
{
SetAttackDamage(GetLevel() * Math.Pow(2, Math.Floor(GetSpellPoints() / 2))
+ 5 * GetEvasivenessPoints());
}

public override void LevelUp()


{
SetLevel(GetLevel() + 1);
SetVitalityPoints(GetVitalityPoints() + 2);
SetEvasivenessPoints(GetEvasivenessPoints() + 3.5);
SetSpellPoints(GetSpellPoints() + 1);
SetAttackDamage(GetLevel() * Math.Pow(2, Math.Floor(GetSpellPoints() / 2))
+ 5 * GetEvasivenessPoints());
}
}
public class MainClass
{
public static void Main(string[] args)
{
Console.Write("Enter Hero Class (1 - Brute, 2 - Champion, 3 - Magus): ");
int heroClass = int.Parse(Console.ReadLine());
Console.Write("Enter Vitality: ");
double vitality = double.Parse(Console.ReadLine());
Console.Write("Enter Evasiveness: ");
double evasiveness = double.Parse(Console.ReadLine());
Console.Write("Enter Spell: ");
double spell = double.Parse(Console.ReadLine());

Hero someHero;
switch (heroClass)
{
case 1:
someHero = new Brute(vitality, evasiveness, spell);
break;
case 2:
someHero = new Champion(vitality, evasiveness, spell);
break;
case 3:
someHero = new Magus(vitality, evasiveness, spell);
break;
default:
return;
}
Tester.Test(someHero);
}
}

You might also like