[Fab] Simple calculator command

Posts 1–8 of 8 · Page 1 of 1
[Fab] Simple calculator command
Alright this is nothing fantastic but I made it quickly cause I was extremely bored XD
Code:
    internal class CalculateCommand : Command
    {
        public CalculateCommand()
            : base("calculate", 0)
        {
        }

        protected override bool Process(Player player, RealmTime time, string[] args)
        {
            int first = int.Parse(args[0]);
            var symbol = string.Join(" ", args[1]);
            int second = int.Parse(args[2]);
            int answer = 0;
            if (symbol == "+")
            {
                answer = first + second;
            }
            if (symbol == "*")
            {
                answer = first * second;
            }
            if (symbol == "-")
            {
                answer = first - second;
            }
            if (symbol == "/")
            {
                answer = first / second;
            }
            player.SendInfo(answer.ToString());
            return true;
        }
    }
What about powers? xD
/useless
Quote Originally Posted by BlackRayquaza View Post
What about powers? xD
/useless
/suckmybutt
Quote Originally Posted by Caesar1928 View Post
Alright this is nothing fantastic but I made it quickly cause I was extremely bored XD
Code:
    internal class CalculateCommand : Command
    {
        public CalculateCommand()
            : base("calculate", 0)
        {
        }

        protected override bool Process(Player player, RealmTime time, string[] args)
        {
            int first = int.Parse(args[0]);
            var symbol = string.Join(" ", args[1]);
            int second = int.Parse(args[2]);
            int answer = 0;
            if (symbol == "+")
            {
                answer = first + second;
            }
            if (symbol == "*")
            {
                answer = first * second;
            }
            if (symbol == "-")
            {
                answer = first - second;
            }
            if (symbol == "/")
            {
                answer = first / second;
            }
            player.SendInfo(answer.ToString());
            return true;
        }
    }
Why not make something usefull instead then? The past commands you've made could be very usefull if they were gathered in one. My idea would be making a new version of a lottery machine like the old one from Doomed Realms Good job
Quote Originally Posted by lkdjnfoskjednfblksjdfn View Post
It seems like you know how to code
before this turns into another big flame thread

i'd like to point out that there are different levels of understanding

for just about everything
Quote Originally Posted by Stellar Spark View Post


before this turns into another big flame thread

i'd like to point out that there are different levels of understanding

for just about everything
Oh yhea, I see :/ I'm being such a problem generator atm. But atleast it keeps the community going.
Quote Originally Posted by lkdjnfoskjednfblksjdfn View Post
Oh yhea, I see :/ I'm being such a problem generator atm. But atleast it keeps the community going.
there will always be times when your interests don't coincide with those of the community :P

provided that you've got your friends and your knowledge ehh you should be fine
Quote Originally Posted by Stellar Spark View Post


there will always be times when your interests don't coincide with those of the community :P

provided that you've got your friends and your knowledge ehh you should be fine
Thanks ;D /99k chars
Posts 1–8 of 8 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?