samedi 5 février 2022

How can I create a random int number to replace the ones that I introduced [duplicate]

This is the part of the code I have, and I need to change the “5” to a random number between 1 and 5 for example. I'm pretty sure that one of the first steps is to remove the “const” after the “private” so it won't not be a constant anymore.

using WarriorWars.Enum;

namespace WarriorWars.Equipment
{
    class Weapon
    {
        private const int GOOD_GUY_DAMAGE = 5;
        private const int BAD_GUY_DAMAGE = 5;

        private int damage;

        public int Damage
        {
            get
            {
                return damage;
            }
        }

        public Weapon(Faction faction)
        {
            switch (faction)
            {
                case Faction.goodGuy:
                    damage = GOOD_GUY_DAMAGE;
                    break;
                case Faction.badGuy:
                    damage = BAD_GUY_DAMAGE;
                    break;
                default:
                    break;
            }
        }
    }
}



Aucun commentaire:

Enregistrer un commentaire