Beispiel #1
0
        public List <string> FizzBuzzer()
        {
            List <string> result = new List <string>();

            if ((Number1 % DivisableBy1 == 0) && (Number1 % DivisableBy2 == 0))
            {
                result.Add(Number1.ToString() + " " + Fizz + Buzz);
            }
            else if (Number1 % DivisableBy1 == 0)
            {
                result.Add(Number1.ToString() + " " + Fizz);
            }
            else if (Number1 % DivisableBy2 == 0)
            {
                result.Add(Number1.ToString() + " " + Buzz);
            }
            else
            {
                result.Add(Number1.ToString());
            }

            if ((Number2 % DivisableBy1 == 0) && (Number2 % DivisableBy2 == 0))
            {
                result.Add(Number2.ToString() + " " + Fizz + Buzz);
            }
            else if (Number2 % DivisableBy1 == 0)
            {
                result.Add(Number2.ToString() + " " + Fizz);
            }
            else if (Number2 % DivisableBy2 == 0)
            {
                result.Add(Number2.ToString() + " " + Buzz);
            }
            else
            {
                result.Add(Number2.ToString());
            }

            if ((Number3 % DivisableBy1 == 0) && (Number3 % DivisableBy2 == 0))
            {
                result.Add(Number3.ToString() + " " + Fizz + Buzz);
            }
            else if (Number3 % DivisableBy1 == 0)
            {
                result.Add(Number3.ToString() + " " + Fizz);
            }
            else if (Number3 % DivisableBy2 == 0)
            {
                result.Add(Number3.ToString() + " " + Buzz);
            }
            else
            {
                result.Add(Number3.ToString());
            }

            if ((Number4 % DivisableBy1 == 0) && (Number4 % DivisableBy2 == 0))
            {
                result.Add(Number4.ToString() + " " + Fizz + Buzz);
            }
            else if (Number4 % DivisableBy1 == 0)
            {
                result.Add(Number4.ToString() + " " + Fizz);
            }
            else if (Number4 % DivisableBy2 == 0)
            {
                result.Add(Number4.ToString() + " " + Buzz);
            }
            else
            {
                result.Add(Number4.ToString());
            }

            if ((Number5 % DivisableBy1 == 0) && (Number5 % DivisableBy2 == 0))
            {
                result.Add(Number5.ToString() + " " + Fizz + Buzz);
            }
            else if (Number5 % DivisableBy1 == 0)
            {
                result.Add(Number5.ToString() + " " + Fizz);
            }
            else if (Number5 % DivisableBy2 == 0)
            {
                result.Add(Number5.ToString() + " " + Buzz);
            }
            else
            {
                result.Add(Number5.ToString());
            }

            return(result);
        }
Beispiel #2
0
    }//update
    #endregion

    #region User Define Methods
    public void CreateEquation()
    {
        Number1 = Random.Range(1, 10);
        Debug.Log(Number1);
        n1.text = Number1.ToString();
        Number2 = Random.Range(1, 10);
        n2.text = Number2.ToString();
        Debug.Log(Number2);
        Number3 = Random.Range(1, 10);
        n3.text = Number3.ToString();
        Debug.Log(Number3);
        o3.text = "=";
        if(Number2 > Number1)
        {
            Answer = Number1 + Number2;
            o1.text = "+";
        }

        else
        {
            if(Random.Range(0, 2) == 0)
            {
                //Add
                Answer = Number1 + Number2;
                o1.text = "+";
            }

            else
            {
                //Sub
                Answer = Number1 - Number2;
                o1.text = "-";
            }
        }
        
        Debug.Log(Answer);

        if (Answer % Number3 == 0)
        {
            Answer = Answer / Number3;
            o2.text = "/";
        }

        else
        {
            Answer = Answer * Number3;
            o2.text = "*";
        }

        Debug.Log(Answer);


        switch (Random.Range(0, 3))
        {
            case 0:
                a1.text = Answer.ToString();
                a2.text = (Answer + 2).ToString();
                a3.text = (Answer + 3).ToString();

                break;

            case 1:
                a2.text = Answer.ToString();
                a3.text = (Answer + 2).ToString();
                a1.text = (Answer + 3).ToString();
                break;

            case 2:
                a3.text = Answer.ToString();
                a1.text = (Answer + 2).ToString();
                a2.text = (Answer + 3).ToString();
                break;
        }//switch


    }//Create Equation