Пример #1
0
        public static void Main()
        {
            sub s = new sub(100, 200);

            s.display();
            Console.ReadLine();
        }
Пример #2
0
        public void TestMethod17()
        {
            // ToString() test
            add a = new add(0, 1, 5);

            Assert.AreEqual("add r0 r1 r5", a.ToString());
            addi ai = new addi(0, 1, 5);

            Assert.AreEqual("addi r0 r1 5", ai.ToString());
            bz bz = new bz(1, 1);

            Assert.AreEqual("bz r1 1", bz.ToString());
            bge bge = new bge(1, 1);

            Assert.AreEqual("bge r1 1", bge.ToString());
            bnz bnz = new bnz(1, 1);

            Assert.AreEqual("bnz r1 1", bnz.ToString());
            ble ble = new ble(1, 1);

            Assert.AreEqual("ble r1 1", ble.ToString());
            finish f = new finish();

            Assert.AreEqual("finish", f.ToString());
            launch l = new launch(1);

            Assert.AreEqual("launch r1", l.ToString());
            ld ld = new ld(2, 1, 3);

            Assert.AreEqual("ld r2 r1 3", ld.ToString());
            mul m = new mul(1, 2, 3);

            Assert.AreEqual("mul r1 r2 r3", m.ToString());
            muli mi = new muli(1, 2, 3);

            Assert.AreEqual("muli r1 r2 3", mi.ToString());
            st s = new st(1, 2, 3);

            Assert.AreEqual("st r1 r2 3", s.ToString());
            sub sub = new sub(1, 2, 3);

            Assert.AreEqual("sub r1 r2 r3", sub.ToString());
            subi subi = new subi(1, 2, 3);

            Assert.AreEqual("subi r1 r2 3", subi.ToString());
        }
Пример #3
0
        public ActionResult Index(sub sandwich)
        {
            // Declare pricing
            double[] subPrice  = new double[] { 4, 4.50, 5, 5.50, 6 };
            double[] sizePrice = new double[] { 4, 6, 8, 10 };
            double[] dealPrice = new double[] { 0, 1, 1.50 };

            // Get input values from form
            string subName = Enum.GetName(typeof(SubName), sandwich.SubName);
            string subSize = Enum.GetName(typeof(SubSize), sandwich.SubSize);
            string deal    = Enum.GetName(typeof(Meal), sandwich.Meal);

            // Calculate Price
            double priceName = subPrice[(int)sandwich.SubName];
            double priceSize = sizePrice[(int)sandwich.SubSize];
            double priceDeal = dealPrice[(int)sandwich.Meal];

            double unitPrice   = (priceName * priceSize);
            double preTaxPrice = priceDeal + (priceName * priceSize);
            double taxPrice    = preTaxPrice * 0.15;
            double totalPrice  = preTaxPrice + taxPrice;

            // Today's date
            DateTime today = DateTime.Today;
            string   date  = today.ToLongDateString();

            // Format currency
            String unitPriceS   = Convert.ToDecimal(unitPrice).ToString("C");
            String priceDealS   = Convert.ToDecimal(priceDeal).ToString("C");
            String preTaxPriceS = Convert.ToDecimal(preTaxPrice).ToString("C");
            String taxS         = Convert.ToDecimal(taxPrice).ToString("C");
            String totalPriceS  = Convert.ToDecimal(totalPrice).ToString("C");

            // Send data to receipt view
            ViewData["subName"]     = subName;
            ViewData["subSize"]     = subSize;
            ViewData["subDeal"]     = deal;
            ViewData["UnitPrice"]   = unitPriceS;
            ViewData["dealPrice"]   = priceDealS;
            ViewData["preTaxPrice"] = preTaxPriceS;
            ViewData["tax"]         = taxS;
            ViewData["totalPrice"]  = totalPriceS;
            ViewData["date"]        = date;

            return(View("Receipt"));
        }
Пример #4
0
    static void Main(string[] args)
    {
        interfaceSample i1 = new Implemntation();

        i1.SampleInterface();
        parent p = new parent();
        child  c = new child();

        Console.WriteLine("calling from parent class");
        c.display();
        c.display1();
        Console.WriteLine("From parent class");
        p.display();
        def d = new def();
        sub s = new sub();

        d.calc();
        s.calc();
        Console.ReadLine();
    }
Пример #5
0
 void Start()
 {
     main         = this;
     illu.enabled = false;
     story.Add("???");
     story.Add("Where am I?");
     story.Add("......");//hello~
     story.Add("Looks like there are hidden speakers in the room and that is where the sound comes from.");
     story.Add("\"Who are you? And what is this place?\"");
     story.Add(""); //obv i locked u here. and if can only get out if you solve all my puzzles!
     story.Add("\"But WHY?\"");
     story.Add(""); //why not?
     story.Add("......");
     story.Add("\"Fine. I solve your puzzles and I can get out right?\"");
     story.Add(""); //yes
     story.Add("\"OK. Oh, and one more thing, why can't I see my legs and body and hands? What did you do?\"");
     story.Add(""); //How do I know? Ask the ones who made this game?
     story.Add("......");
     story.Add("\"Whatever, I am just going to solve your puzzles.\"");
     story.Add("");
     story.Add("Looks like this is the first puzzle.");// phase 2
     story.Add("I need to put these pieces back to form a picture.\nI can only slide these pieces to an adjacent empty slot and I cannot pick anything up.");
     story.Add("I only got one chance at this and if I mess up I will permanently be locked here.\nSo I should have the answer in my head before I even touch it.");
     story.Add("How do I know all that just by looking, you ask?");
     story.Add("Hey, listen. I am just reading what's on the script OK?\n So deal with it.");
     story.Add("");
     story.Add("???");
     story.Add(""); // looks like the puzzle is solved
     story.Add("What happened?\nI didn't touch it yet, it just solved itself?");
     story.Add(""); // correct, which means that YOU did not solve the puzzle and therefore you will be locked here forever.
     story.Add("Can I say something?");
     story.Add(""); // wat
     story.Add("W T F ?\n╭∩╮( ̄▽ ̄)╭∩╮");
     story.Add(""); // XD
     story.Add("");
     sfxSource.Play();
 }
Пример #6
0
 private void OnDestroy()
 {
     inst = null;
 }
Пример #7
0
 private void Awake()
 {
     inst = this;
 }
Пример #8
0
    private void CreateObject(GameObject layer, LoaderObject node, Vector2 point, Vector2 gridSize, LoaderCallBack cb, LoaderPostCallBack cbPost
                              , LoaderObject loaderObj, sub subObj)
    {
        GameObject obj;
        string     layerName;

        if (layer != null)
        {
            layerName = layer.name;
        }
        else
        {
            layerName = _Name;
        }

        //prefab
        if (node.prefab != null && node.prefab.Length > 0)
        {
            obj = Resources.Load <GameObject>(node.prefab);
            if (node.ui == false)
            {
                mPos.SetGameObjectSize(ref obj, gridSize.x, gridSize.y);
                obj.transform.position = new Vector3(point.x, point.y, 0);
            }
        }
        else
        {
            obj = cb(layerName, node.name, node.tag, point, gridSize);
        }

        if (obj != null)
        {
            obj      = UnityEngine.Object.Instantiate(obj);
            obj.tag  = node.tag;
            obj.name = node.name;
            //ui
            if (node.ui == true)
            {
                obj.transform.position = mCamera.WorldToScreenPoint(new Vector3(point.x, point.y, 0));
                if (layer == null)
                {
                    obj.transform.SetParent(mCanvas);
                }
                else
                {
                    obj.transform.SetParent(layer.transform);
                }

                //resizing
                if (node.prefab != null && node.prefab.Length > 0)
                {
                    //span 처리
                    if (subObj._InnerMargin.x > 0 || subObj._InnerMargin.y > 0)
                    {
                        gridSize.x = (gridSize.x * (loaderObj.span.x + 1)) + (subObj._InnerMargin.x * 2.0f * loaderObj.span.x);
                        gridSize.y = (gridSize.y * (loaderObj.span.y + 1)) + (subObj._InnerMargin.y * 2.0f * loaderObj.span.y);
                    }
                    Vector3 gridScreenSize = mCamera.WorldToScreenPoint(new Vector3(point.x + gridSize.x, point.y + gridSize.y, 0));
                    gridScreenSize.x -= obj.transform.position.x;
                    gridScreenSize.y -= obj.transform.position.y;

                    obj.GetComponent <RectTransform>().sizeDelta = new Vector2(gridScreenSize.x, gridScreenSize.y);
                }
                //onclick
                Button btn = obj.GetComponent <Button>();
                if (btn != null)
                {
                    btn.onClick.AddListener(() => { mButtonCallBack(obj); });
                }
            }
            //text
            if (node.text != null)
            {
                Text txt = obj.GetComponent <Text>();
                if (txt == null)
                {
                    txt = obj.GetComponentInChildren <Text>();
                }
                if (txt != null)
                {
                    txt.text = node.text;
                }
            }

            if (mObjects.ContainsKey(node.name) == false)
            {
                mObjects[node.name] = new List <GameObject>();
            }
            mObjects[node.name].Add(obj);

            if (cbPost != null)
            {
                cbPost(obj, layerName);
            }
        }
    }
Пример #9
0
    public void AddComponents(LoaderCallBack cb, LoaderPostCallBack cbPost = null)
    {
        List <Vector2> points   = mPos.GetGridPoints(_Margin, _GridDim);
        Vector2        gridSize = mPos.GetGridSize(_Margin, _InnerMargin, _GridDim);

        mObjects["BG"] = new List <GameObject>();

        for (int n = 0; n < _Objects.Count; n++)
        {
            int idx = (_Objects[n].position.y * _GridDim.x) + _Objects[n].position.x;
            if (idx > points.Count)
            {
                throw new Exception("Invalid index. check _GridDim & _Objects position");
            }

            sub s = new sub();
            CreateObject(null, _Objects[n], GetPosition(points[idx], gridSize, _Objects[n].pivot), gridSize, cb, cbPost, _Objects[n], s);
        }

        //_subs
        for (int i = 0; i < _Subs.Count; i++)
        {
            sub            s      = _Subs[i];
            List <Vector2> minMax = mPos.GetGridMinMax(_Margin, _InnerMargin, _GridDim, s._From, s._To);
            points   = mPos.GetGridPoints(s._Margin, s._GridDim, minMax[0], minMax[1]);
            gridSize = mPos.GetGridSize(minMax[0], minMax[1], s._Margin, s._InnerMargin, s._GridDim);
            GameObject   layer;
            List <float> bgColor;
            //bg color
            if (s._BGColor.Count > 0)
            {
                bgColor = s._BGColor;
            }
            else
            {
                bgColor = new List <float>();
                for (int n = 0; n < 4; n++)
                {
                    bgColor.Add(0.0f);
                }
            }
            layer = CreatePanel(s._Name, minMax, bgColor, s._Margin);
            mObjects["BG"].Add(layer);

            for (int n = 0; n < s._Objects.Count; n++)
            {
                LoaderObject node = s._Objects[n];
                int          idx  = (node.position.y * s._GridDim.x) + node.position.x;
                if (idx > points.Count)
                {
                    throw new Exception("Invalid index. check _GridDim & _Objects position. " + s._Name);
                }

                CreateObject(layer, node, GetPosition(points[idx], gridSize, node.pivot), gridSize, cb, cbPost, node, s);
            }
            //Draw Line
            if (mDrawGridSubSet.Contains(s._Name) == true || s._DrawGridLine == true)
            {
                mPos.DrawGrid(s._Margin, s._GridDim, minMax[0], minMax[1], mCanvas);
            }
        }
    }
Пример #10
0
        public ActionResult Index(sub sandwich)
        {
            // Declare pricing
            double[] subPrice  = new double[] { 4, 4.50, 5, 5.50, 6 };
            double[] sizePrice = new double[] { 4, 6, 8, 10 };
            double[] dealPrice = new double[] { 0, 1, 1.50 };

            // Get input values from form
            string subName = Enum.GetName(typeof(SubName), sandwich.SubName);
            string subSize = Enum.GetName(typeof(SubSize), sandwich.SubSize);
            string deal    = Enum.GetName(typeof(Meal), sandwich.Meal);
            // Sheet 5 Quantity
            int qty = sandwich.Quantity;

            // Calculate Price
            double priceName = subPrice[(int)sandwich.SubName];
            double priceSize = sizePrice[(int)sandwich.SubSize];
            double priceDeal = dealPrice[(int)sandwich.Meal];

            // Original calculation

            /*
             * double unitPrice = (priceName * priceSize);
             * double preTaxPrice = priceDeal + (priceName * priceSize);
             * double taxPrice = preTaxPrice * 0.15;
             * double totalPrice = preTaxPrice + taxPrice;
             */

            double unitPrice     = (priceName * priceSize);
            double fullMealPrice = unitPrice + priceDeal;
            double preTaxPrice   = qty * (priceDeal + (priceName * priceSize));
            double taxPrice      = preTaxPrice * 0.15;
            double totalPrice    = preTaxPrice + taxPrice;

            // Today's date
            DateTime today = DateTime.Today;
            string   date  = today.ToLongDateString();

            // Format currency
            String unitPriceS     = Convert.ToDecimal(unitPrice).ToString("C");
            String priceDealS     = Convert.ToDecimal(priceDeal).ToString("C");
            String fullMealPriceS = Convert.ToDecimal(fullMealPrice).ToString("C");
            String preTaxPriceS   = Convert.ToDecimal(preTaxPrice).ToString("C");
            String taxS           = Convert.ToDecimal(taxPrice).ToString("C");
            String totalPriceS    = Convert.ToDecimal(totalPrice).ToString("C");

            // Send data to receipt view
            ViewData["subName"]       = subName;
            ViewData["subSize"]       = subSize;
            ViewData["subDeal"]       = deal;
            ViewData["UnitPrice"]     = unitPriceS;
            ViewData["dealPrice"]     = priceDealS;
            ViewData["fullMealPrice"] = fullMealPriceS;
            ViewData["quantity"]      = qty;
            ViewData["preTaxPrice"]   = preTaxPriceS;
            ViewData["tax"]           = taxS;
            ViewData["totalPrice"]    = totalPriceS;
            ViewData["date"]          = date;

            // Add Current Sub to Session
            // If Session exists, then the order list will be the session.
            // Then add the current sandwich to the list.
            List <sub> orders = new List <sub>();

            if (Session["Orders"] != null)
            {
                orders = (List <sub>)Session["Orders"];
            }
            orders.Add(sandwich);
            Session["Orders"] = orders;

            // Tax Calculations
            if (Session["tax"] != null)
            {
                double updatedTaxPrice = taxPrice + (double)Session["tax"];
                Session["tax"] = updatedTaxPrice;
            }
            else
            {
                Session["tax"] = taxPrice;
            }

            // Income Calculations
            // Calculate profit only (taxes doesn't count)
            if (Session["income"] != null)
            {
                double updatedIncome = preTaxPrice + (double)Session["income"];
                Session["income"] = updatedIncome;
            }
            else
            {
                Session["income"] = preTaxPrice;
            }

            // Return Receipt View
            return(View("Receipt"));
        }
Пример #11
0
 if (src[i..].Contains(sub, System.StringComparison.OrdinalIgnoreCase))
Пример #12
0
        static void Main(string[] args)
        {
            modelinho Modelinho = new modelinho();

            Console.WriteLine("CALCULADORA DA ALEGRIA");

            bool continuar = true;

            while (continuar)
            {
                Console.WriteLine("1-Soma");
                Console.WriteLine("2-Subtração");
                Console.WriteLine("3-Divisão");
                Console.WriteLine("4-Multiplicação");
                Console.WriteLine("Escolha uma operação");

                Modelinho.opcao = Convert.ToInt32(Console.ReadLine());
                Console.Clear();

                Console.WriteLine("Entre com o numero:");
                Modelinho.valor1 = Convert.ToDecimal(Console.ReadLine());
                Console.WriteLine("Entre com o outro numero");
                Modelinho.valor2 = Convert.ToDecimal(Console.ReadLine());

                switch (Modelinho.opcao)
                {
                case 1:
                    soma    Soma  = new soma(Modelinho.valor1, Modelinho.valor2);;
                    decimal rSoma = Soma.result();

                    Console.WriteLine("Total: ");
                    Console.WriteLine(rSoma);

                    break;



                case 2:

                    sub     Sub  = new sub(Modelinho.valor1, Modelinho.valor2);;
                    decimal rSub = Sub.result();

                    Console.WriteLine("Total: ");
                    Console.WriteLine(rSub);

                    break;

                case 3:

                    divisao Div  = new divisao(Modelinho.valor1, Modelinho.valor2);;
                    decimal rDiv = Div.result();

                    Console.WriteLine("Total: ");
                    Console.WriteLine(rDiv);

                    break;

                case 4:

                    mult    Mult  = new mult(Modelinho.valor1, Modelinho.valor2);;
                    decimal rMult = Mult.result();

                    Console.WriteLine("Total: ");
                    Console.WriteLine(rMult);

                    break;
                }
            }
        }