diff --git a/kasic/Commands/Add.cs b/kasic/Commands/Add.cs index 7c4fd7d..52f28ca 100644 --- a/kasic/Commands/Add.cs +++ b/kasic/Commands/Add.cs @@ -16,9 +16,11 @@ public Add() : base("add") CommandSettings = new CommandSettings() { MinArgs = 2, - MaxArgs = 2, + MaxArgs = 4, ArgumentList = new ArgumentList(new List() { + KasicType.NUMBER, + KasicType.NUMBER, KasicType.NUMBER, KasicType.NUMBER }), diff --git a/kasic/Commands/Divide.cs b/kasic/Commands/Divide.cs index ef4a14e..62fb680 100644 --- a/kasic/Commands/Divide.cs +++ b/kasic/Commands/Divide.cs @@ -1,7 +1,44 @@ +using System; +using System.Collections.Generic; +using kasic.Kasic; +using kasic.Logging; +using kasic.Utils; +using OperationResult; + namespace kasic.Commands { - public class Divide + public class Divide : Command { - + public Divide() : base("div") + { + CommandSettings = new CommandSettings() + { + MinArgs = 2, + MaxArgs = 2, + ArgumentList = new ArgumentList(new List() + { + KasicType.NUMBER, + KasicType.NUMBER + }), + ReturnType = KasicType.NUMBER, + }; + } + + public override Result Run(Context context, Arguments arguments, List flags) + { + var firstNumber = arguments.AsNumber(context, 0); + if (firstNumber.IsError) + { + return Helpers.Error(firstNumber.Error); + } + + var secondNumber = arguments.AsNumber(context, 1); + if (secondNumber.IsError) + { + return Helpers.Error(secondNumber.Error); + } + + return new ReturnObject(this, firstNumber.Value / secondNumber.Value); + } } } \ No newline at end of file diff --git a/kasic/Commands/Mult.cs b/kasic/Commands/Mult.cs index 3ff3b50..c053d92 100644 --- a/kasic/Commands/Mult.cs +++ b/kasic/Commands/Mult.cs @@ -14,9 +14,11 @@ public Mult() : base("mult") CommandSettings = new CommandSettings() { MinArgs = 2, - MaxArgs = UInt32.MaxValue, + MaxArgs = 4, ArgumentList = new ArgumentList(new List() { + KasicType.NUMBER, + KasicType.NUMBER, KasicType.NUMBER, KasicType.NUMBER }),