0

大家好,我最近尝试使用 Cosmos 构建自己的操作系统,所以我已经完成了 enogh 命令来满足标准用户的需求,我的问题是程序不能使用多个命令,我想做像 cmd 和这里是使用 System; 的代码示例 使用 Cosmos.Compiler.Builder;

namespace CosmosBoot1

{

class Program
{
    #region Cosmos Builder logic
    // Most users wont touch this. This will call the Cosmos Build tool
    [STAThread]
    static void Main(string[] args)
    {
        BuildUI.Run();
    }
    #endregion
    public static string[] outputline = { "Welcome user" };

    // Main entry point of the kernel
    public static void Init()
    {
        var xBoot = new Cosmos.Sys.Boot();
        xBoot.Execute();
        Console.WriteLine("Welcome to Tammaa OS ");
        Console.WriteLine("Please insert a Command");
        Drawconsole();
        string uinput = "";
        uinput = Console.ReadLine();
        if (uinput == "shutdown")
        {
            Cosmos.Sys.Deboot.ShutDown();
        }
        else if (uinput == "help")
        {
            Console.WriteLine("shutdown \t Turn off the system");
            Console.WriteLine("restart \t Restarts the system");
        }
        else if (uinput == "calc")
        {
            Console.WriteLine("Please enter the the syntax");
            String operation = Console.ReadLine();
            uint usernum1, usernum2;
           Console.WriteLine("Please insert the 2 numbers");
           usernum1 = userint(0, 100, 101);
           usernum2 = userint(0, 100, 101);
           if (operation == "+")
           {
               Console.WriteLine((usernum1 + usernum2).ToString());
               Drawconsole();
           }
           else if (operation == "-")
           {
               Console.WriteLine((usernum1 - usernum2).ToString());
               Drawconsole();
           }
           else if (operation == "*")
           {
               Console.WriteLine((usernum1 * usernum2).ToString());
               Drawconsole();
           }
           else if (operation == "/")
           {
               Console.WriteLine((usernum1 / usernum2).ToString());
               Drawconsole();
           }
           else
           {
               Console.WriteLine("An unexcepected error  stoped the proccess please chack your data and try again");
               Drawconsole();
           }
        }
        else
        {
            Console.WriteLine("Unknown Command");
            Console.WriteLine("Type help to get vaild commands,Please");
            Drawconsole();
        }

        while (true)
            ;

    }
    public static uint userint(uint start, uint end, uint Default)
    {
        uint a;
        String userinput = Console.ReadLine();
        for (a = start; a <= end; a++)
        {
            if (a.ToString() == userinput)
            {
                return a;
            }
        }
        return Default;
    }
    public static void Drawconsole()
    {
        Console.Clear();
        Console.WriteLine("OS command here>");

    }
}

}`

4

0 回答 0