BuzzSaw


/******************************************
 * BuzzSaw.cs
 *
 * Javier Kadry
 *
 * INSTRUCTION:
 * Write a program that prints the numbers 1 to 100.
 * For multiples of 3, output the string "Buzz" instead of the number.
 * For multiples of 5, output the string "Saw" instead of the number.
 * For multiples of 3 & 5, output "BuzzSaw" instead of the number.
 ******************************************/
using UnityEngine;
using System.Collections;

public class BuzzSaw : MonoBehaviour 
{
    public GameObject plane;
    public Material[] newMatBuzz;
    public Material[] newMatSaw;
    public Material[] newMatBuzzSaw;

    private int i = 0;
    
    bool isMultiple;

    void Incrementer()
    {
        isMultiple = false;

        i++;

        if (i % 3 == 0)
        {
            isMultiple = true;
            Debug.Log ("Buzz");
            plane.renderer.material = newMatBuzz[Random.Range(0,newMatBuzz.Length)];
        }

        if (i % 5 == 0)
        {
            isMultiple = true;
            Debug.Log ("Saw");
            plane.renderer.material = newMatSaw[Random.Range(0,newMatSaw.Length)];
        }

        if (i % 15 == 0)
        {
            isMultiple = true;
            Debug.Log ("BuzzSaw");
            plane.renderer.material = newMatBuzzSaw[Random.Range(0,newMatBuzzSaw.Length)];
        }

        if (!isMultiple)
        {
            Debug.Log(i);
        }

        if( i == 101)
        {
            i = 0;
        }

    }
    void OnGUI()
    {
        if (!isMultiple)
        {
            GUI.Label(new Rect(10, 120, 150, 20), "" + i);
        }

        if (GUI.Button(new Rect(10, 10, 150, 100), "Click Me!"))
        {
            Incrementer();
        }

    }
}

Leave a Reply

Your email address will not be published. Required fields are marked *