示例#1
0
    void findContact()
    {
        SnapsEngine.SetTitleString("Find Contact");

        string name = SnapsEngine.ReadString("Enter contact name");

        bool foundAContact = false;

        SnapsEngine.ClearTextDisplay();

        foreach (Contact contact in contacts)
        {
            if (contact.ContactName == name)
            {
                SnapsEngine.AddLineToTextDisplay("Name: " + contact.ContactName);
                SnapsEngine.AddLineToTextDisplay("Address: " + contact.ContactAddress);
                SnapsEngine.AddLineToTextDisplay("Phone: " + contact.ContactPhone);
                SnapsEngine.AddLineToTextDisplay("Minutes: " + contact.ContactMinutesSpent.ToString());
                foundAContact = true;
                break;
            }
        }

        if (!foundAContact)
        {
            SnapsEngine.AddLineToTextDisplay("Contact not found");
        }

        SnapsEngine.WaitForButton("Continue");
        SnapsEngine.ClearTextDisplay();
    }
示例#2
0
    public void FindContact()
    {
        //get the name of contact to search for
        string name = SnapsEngine.ReadString("Enter contact name");

        // variable to hold the address and phone being returned
        string contactAddress;
        string contactPhone;

        if (FetchContact(name: name, address: out contactAddress, phone: out contactPhone) == true)
        {
            //got the contact details display them
            SnapsEngine.ClearTextDisplay();
            SnapsEngine.AddLineToTextDisplay("Name: " + name);
            SnapsEngine.AddLineToTextDisplay("Address: " + contactAddress);
            SnapsEngine.AddLineToTextDisplay("Phone: " + contactPhone);
        }

        else
        {
            SnapsEngine.DisplayString("Name not found");
        }

        SnapsEngine.WaitForButton("Continue");

        SnapsEngine.ClearTextDisplay();
    }
示例#3
0
    /// <summary>
    /// Asks the user for a contact name and displays it
    /// </summary>
    void FindContact()
    {
        // Get the name of the contact to search for
        string name = SnapsEngine.ReadString("Enter contact name");

        // Variables to hold the names address being fetched
        string contactAddress, contactPhone;

        if (FetchContact(name: name, address: out contactAddress, phone: out contactPhone))
        {
            // Got the contact details - display them
            SnapsEngine.ClearTextDisplay();

            SnapsEngine.AddLineToTextDisplay("Name: " + name);
            SnapsEngine.AddLineToTextDisplay("Address: " + contactAddress);
            SnapsEngine.AddLineToTextDisplay("Phone: " + contactPhone);
        }
        else
        {
            // Tell the user the name was not found
            SnapsEngine.DisplayString("Name not found");
            ContactSearch();
        }

        // Give the user a chance to view the details
        SnapsEngine.WaitForButton("Continue");

        // Clear the display
        SnapsEngine.ClearTextDisplay();

        // Continue searching
        ContactSearch();
    }
示例#4
0
    void addMinutes()
    {
        SnapsEngine.SetTitleString("Add Minutes");

        string name    = SnapsEngine.ReadString("Enter contact name");
        int    minutes = SnapsEngine.ReadInteger("Enter contact minutes");

        bool foundAContact = false;

        SnapsEngine.ClearTextDisplay();

        for (int position = 0; position < contacts.Length; position = position + 1)
        {
            if (contacts[position].ContactName == name)
            {
                SnapsEngine.AddLineToTextDisplay("Added " + minutes + " minutes\n" +
                                                 "to " + name);
                contacts[position].ContactMinutesSpent = contacts[position].ContactMinutesSpent + minutes;
                foundAContact = true;
                break;
            }
        }

        if (!foundAContact)
        {
            SnapsEngine.AddLineToTextDisplay("Contact not found");
        }

        SnapsEngine.WaitForButton("Continue");
        SnapsEngine.ClearTextDisplay();
    }
示例#5
0
    void FindContact()
    {
        string name = SnapsEngine.ReadString("Who are you looking for?");
        // asks user what contact's information he/she are looking for.

        string contactPhone, contactAddress;

        // variables to place values that are in local storage

        if (FetchContact(name: name, address: out contactAddress, phone: out contactPhone))
        // if there is information on a contact the user entered
        {
            SnapsEngine.ClearTextDisplay();
            SnapsEngine.AddLineToTextDisplay("Name:" + name);
            SnapsEngine.AddLineToTextDisplay("Address:" + contactAddress);
            SnapsEngine.AddLineToTextDisplay("Phone:" + contactPhone);

            // display the contact's information
        }

        else
        {
            SnapsEngine.DisplayString("This person is not on file");

            // if the person does no exist, let user know.
        }

        SnapsEngine.WaitForButton("Continue");

        // a Continue button appears for the user to click on to find a different contact or add a contact

        SnapsEngine.ClearTextDisplay();
    }
    public void StartProgram()
    {
        SnapsEngine.SetTitleString("Ice Cream Sales");

        // Find out how many sales values are being stored
        int noOfStands = SnapsEngine.ReadInteger("How many ice cream stands");

        int[] sales = new int[noOfStands];

        // Loop round and read the sales values
        for (int count = 0; count < sales.Length; count = count + 1)
        {
            // User likes to count from 1, not zero
            int displayCount = count + 1;
            sales[count] = SnapsEngine.ReadInteger("Enter the sales for stand " + displayCount);
        }

        // Got the sales figures, now display them

        SnapsEngine.ClearTextDisplay();

        // Add a line to the display for each sales figure
        for (int count = 0; count < sales.Length; count = count + 1)
        {
            SnapsEngine.AddLineToTextDisplay("Sales: " + sales[count]);
        }
    }
    public void StartProgram()
    {
        int[] sales = new int[]
        {
            50, 54, 29, 33, 22, 100, 45, 54, 89, 75
        };

        SnapsEngine.SetTitleString("Sort Demo");

        for (int pass = 0; pass < sales.Length - 1; pass = pass + 1)
        {
            for (int i = 0; i < sales.Length - 1; i = i + 1)
            {
                if (sales[i] > sales[i + 1])
                {
                    // the elements are in the wrong order, need to swap them round
                    int temp = sales[i];
                    sales[i]     = sales[i + 1];
                    sales[i + 1] = temp;
                }
            }
        }

        // Got the sorted figures, now display them

        SnapsEngine.ClearTextDisplay();

        // Add a line to the display for each sales figure
        for (int count = 0; count < sales.Length; count = count + 1)
        {
            SnapsEngine.AddLineToTextDisplay("Sales: " + sales[count]);
        }
    }
示例#8
0
    public void StartProgram()
    {
        SnapsEngine.SetTitleString("Guest List");

        // Find out how many sales values are being stored
        int noOfGuests = SnapsEngine.ReadInteger("How many guests will there be?");

        int[]  guests       = new int[noOfGuests];
        string nameOfGuests = SnapsEngine.ReadString("Enter the name for each guest");

        string[] guestNames = new string[nameOfGuests];
        // Loop round and read the sales values
        for (int count = 0; count < guests.Length; count = count + 1)
        {
            // User likes to count from 1, not zero
            int displayCount = count + 1;
            guestNames[count] = SnapsEngine.ReadString("Enter the name for guest " + displayCount);
        }

        // Got the sales figures, now display them

        SnapsEngine.ClearTextDisplay();

        // Add a line to the display for each sales figure
        for (int count = 0; count < guests.Length; count = count + 1)
        {
            SnapsEngine.AddLineToTextDisplay("Name: " + guests[count]);
        }
    }
示例#9
0
    public void StartProgram()
    {
        // To save us from typing in the values, I've pre-set them into an array
        // of integers.
        int[] sales = new int[]
        {
            50, 54, 29, 33, 22, 100, 45, 54, 89, 75
        };

        SnapsEngine.SetTitleString("Sort Demo");

        // Single pass
        for (int count = 0; count < sales.Length - 1; count = count + 1)
        {
            if (sales[count] > sales[count + 1])
            {
                // the elements are in the wrong order, need to swap them round
                int temp = sales[count];
                sales[count]     = sales[count + 1];
                sales[count + 1] = temp;
            }
        }

        // Got the sales figures, now display them

        SnapsEngine.ClearTextDisplay();

        // Add a line to the display for each sales figure
        for (int count = 0; count < sales.Length; count = count + 1)
        {
            SnapsEngine.AddLineToTextDisplay("Sales: " + sales[count]);
        }
    }
示例#10
0
文件: Car.cs 项目: TorryWilson/CSharp
    public void StartProgram()
    {
        SnapsEngine.DisplayImageFromUrl("https://st.hzcdn.com/simgs/1711fefa0603fedf_4-1809/industrial-novelty-signs.jpg"); // add background image of a diner sign
        SnapsEngine.SetTitleString("Car Counter");
        // variables that count the number of cars, vans, bikes, and trucks
        int car   = 0;
        int van   = 0;
        int bike  = 0;
        int truck = 0;


        bool button = true;

        // loop that allows user to keep clicking on different transportations until user wants sum.
        while (button == true)
        {
            // stores what user selects from the 5 buttons
            string pick = SnapsEngine.SelectFrom5Buttons("Car", "Van", "Bike", "Truck", "Sum");
            // adds one to whichever user picks
            if (pick == "Car")
            {
                car = car + 1;
            }
            if (pick == "Van")
            {
                van = van + 1;
            }
            if (pick == "Bike")
            {
                bike = bike + 1;
            }
            if (pick == "Truck")
            {
                truck = truck + 1;
            }
            if (pick == "Sum")
            {
                // if user picks sum text is cleared and then program gives user the amount of times he/she clicked on each transportation.
                SnapsEngine.ClearTextDisplay();
                SnapsEngine.AddLineToTextDisplay("There were " + car.ToString() + " cars");
                SnapsEngine.Delay(10);
                SnapsEngine.AddLineToTextDisplay("There were " + van.ToString() + " vans");
                SnapsEngine.Delay(10);
                SnapsEngine.AddLineToTextDisplay("There were " + bike.ToString() + " bikes");
                SnapsEngine.Delay(10);
                SnapsEngine.AddLineToTextDisplay("There were " + truck.ToString() + " trucks");
                SnapsEngine.Delay(10);
                // ends the ability to select transportations.
                button = false;
            }
            {
            }
        }
    }
示例#11
0
    public static void StartProgram()
    {
        Contact rob = new Contact(name: "Rob", address: "Rob's House", phone: "Rob's Phone");

        SnapsEngine.SetTitleString("Contact Structure Demo");

        SnapsEngine.ClearTextDisplay();
        SnapsEngine.AddLineToTextDisplay("Name: " + rob.ContactName);
        SnapsEngine.AddLineToTextDisplay("Address: " + rob.ContactAddress);
        SnapsEngine.AddLineToTextDisplay("Phone: " + rob.ContactPhone);
        SnapsEngine.AddLineToTextDisplay("Minutes: " + rob.ContactMinutesSpent.ToString());
    }
    public static void StartProgram()
    {
        string rssText = SnapsEngine.GetWebPageAsString("http://feeds.bbci.co.uk/news/rss.xml");

        XElement rssElements = XElement.Parse(rssText);

        SnapsEngine.SetTitleString("Headlines from Rob");

        SnapsEngine.ClearTextDisplay();
        foreach (XElement element in rssElements.Element("channel").Elements("item"))
        {
            SnapsEngine.AddLineToTextDisplay(element.Element("title").Value);
        }
    }
示例#13
0
    public static void StartProgram()
    {
        CupCake cheeseSurprise;

        cheeseSurprise.Name        = "Cheese Surprise";
        cheeseSurprise.Ingredients = "Cheese, flour, sugar";
        cheeseSurprise.Recipe      = "Mix cheese, flour and sugar, cook for 30 minutes";

        SnapsEngine.SetTitleString("CupCake Structure Demo");

        SnapsEngine.ClearTextDisplay();
        SnapsEngine.AddLineToTextDisplay("Name: " + cheeseSurprise.Name);
        SnapsEngine.AddLineToTextDisplay("Ingredients: " + cheeseSurprise.Ingredients);
        SnapsEngine.AddLineToTextDisplay("Recipe: " + cheeseSurprise.Recipe);
    }
示例#14
0
    void EditContact()
    {
        SnapsEngine.DisplayString("Edit the contact");

        string name    = SnapsEngine.ReadString("Enter edited contact name");
        string address = SnapsEngine.ReadMultiLineString("Enter edited address");
        string phone   = SnapsEngine.ReadString("Enter edited phone");

        StoreEditedContact(name: name, address: address, phone: phone);

        SnapsEngine.AddLineToTextDisplay("Name: " + name);
        SnapsEngine.AddLineToTextDisplay("Address: " + address);
        SnapsEngine.AddLineToTextDisplay("Phone: " + phone);

        SnapsEngine.WaitForButton("Continue");
        // Clear the display
        SnapsEngine.ClearTextDisplay();
    }
    public void StartProgram()
    {
        int[] sales = new int[]
        {
            50, 54, 29, 33, 22, 100, 45, 54, 89, 75
        };

        SnapsEngine.SetTitleString("Sort Demo");

        for (int pass = 0; pass < sales.Length - 1; pass = pass + 1)
        {
            // clear the swap flag for this pass
            bool doneSwap = false;

            // Make a pass down the array swapping elements
            for (int i = 0; i < sales.Length - 1; i = i + 1)
            {
                if (sales[i] > sales[i + 1])
                {
                    // the elements are in the wrong order, need to swap them round
                    int temp = sales[i];
                    sales[i]     = sales[i + 1];
                    sales[i + 1] = temp;
                    doneSwap     = true;
                }
            }
            if (!doneSwap)
            {
                // quit the sort if we didn't do any swaps
                break;
            }
        }

        // Got the sorted figures, now display them

        SnapsEngine.ClearTextDisplay();

        // Add a line to the display for each sales figure
        for (int count = 0; count < sales.Length; count = count + 1)
        {
            SnapsEngine.AddLineToTextDisplay("Sales: " + sales[count]);
        }
    }
示例#16
0
    public void StartProgram()
    {
        SnapsEngine.SetTitleString("Mystery Program 2");

        string inputText = SnapsEngine.ReadString("Enter something please");

        if (inputText.Length > 10)
        {
            inputText = inputText.Substring(0, 10);
        }

        SnapsEngine.AddLineToTextDisplay(inputText);

        foreach (char ch in inputText)
        {
            int chVal = (int)ch;
            SnapsEngine.AddLineToTextDisplay("code = " + chVal);
        }
    }
示例#17
0
    void addMinutes()
    {
        SnapsEngine.SetTitleString("Add Minutes");
        bool   foundContact = false;
        string name         = SnapsEngine.ReadString("Enter contact name");

        foreach (Contact contact in contacts)
        {
            if (contact.ContactName == name)
            {
                foundContact = true;
                int minutes = SnapsEngine.ReadInteger("Enter contact minutes");

                while (minutes <= 0)
                {
                    minutes = SnapsEngine.ReadInteger("You entered an invalid number. \nPlease enter a number greater than zero.");
                }

                SnapsEngine.ClearTextDisplay();

                for (int position = 0; position < contacts.Length; position = position + 1)
                {
                    if (contacts[position].ContactName == name)
                    {
                        SnapsEngine.AddLineToTextDisplay("Added " + minutes + " minutes\n" +
                                                         "to " + name);
                        contacts[position].ContactMinutesSpent = contacts[position].ContactMinutesSpent + minutes;
                        SnapsEngine.WaitForButton("Continue");
                        SnapsEngine.ClearTextDisplay();
                    }
                }
            }
        }

        if (foundContact == false)
        {
            SnapsEngine.AddLineToTextDisplay("Contact not found");
            SnapsEngine.WaitForButton("Continue");
            SnapsEngine.ClearTextDisplay();
        }
    }
示例#18
0
    void FindContact()
    {
        string name = SnapsEngine.ReadString("Enter contact name");

        string contactAddress, contactPhone;

        if (FetchContact(name: name, address: out contactAddress, phone: out contactPhone))
        {
            SnapsEngine.ClearTextDisplay();

            SnapsEngine.AddLineToTextDisplay("Name: " + name);
            SnapsEngine.AddLineToTextDisplay("Address: " + contactAddress);
            SnapsEngine.AddLineToTextDisplay("Phone: " + contactPhone);
        }
        else
        {
            SnapsEngine.DisplayString("Name not found");
        }

        SnapsEngine.WaitForButton("Continue");

        SnapsEngine.ClearTextDisplay();
    }
    public void StartProgram()
    {
        SnapsEngine.SetTitleString("Party Guests");

        // Find out how many guests are coming to the party
        int numOfGuests = SnapsEngine.ReadInteger("How many guests are coming to the party?");

        string[] guests = new string[numOfGuests];

        // Loop round and read the sales values
        for (int count = 0; count < guests.Length; count = count + 1)
        {
            if (count == 0)
            {
                guests[count] = SnapsEngine.ReadString("Enter the name of your first guest:");
            }
            else if (count == guests.Length)
            {
                guests[count] = SnapsEngine.ReadString("Enter the name of your last guest:");
            }
            else
            {
                guests[count] = SnapsEngine.ReadString("Enter the name of your next guest:");
            }
        }

        // Got the guest names, now display them

        SnapsEngine.ClearTextDisplay();

        // Add a line to the display for each sales figure
        for (int count = 0; count < guests.Length; count = count + 1)
        {
            int displayCount = count + 1;
            SnapsEngine.AddLineToTextDisplay("Guest Number " + displayCount + ": " + guests[count]);
        }
    }
    public void StartProgram()
    {
        SnapsEngine.SetTitleString("Number of Guests");

        int noOfGuests = SnapsEngine.ReadInteger("How many guests are at the party");

        string[] guests = new string[noOfGuests];
        int      count;
        int      displayCount;

        for (count = 0; count < guests.Length; count = count + 1)
        {
            displayCount  = count + 1;
            guests[count] = SnapsEngine.ReadString("Enter the name of guest number " + displayCount);
        }

        SnapsEngine.ClearTextDisplay();

        for (count = 0; count < guests.Length; count = count + 1)
        {
            displayCount = count + 1;
            SnapsEngine.AddLineToTextDisplay("Guest " + displayCount + ": " + guests[count]);
        }
    }
示例#21
0
    void displaySummary()
    {
        SnapsEngine.SetTitleString("Display Summary");

        for (int pass = 0; pass < contacts.Length - 1; pass = pass + 1)
        {
            for (int i = 0; i < contacts.Length - 1; i = i + 1)
            {
                if (contacts[i].ContactMinutesSpent < contacts[i + 1].ContactMinutesSpent)
                {
                    // the elements are in the wrong order, need to swap them round
                    Contact temp = contacts[i];
                    contacts[i]     = contacts[i + 1];
                    contacts[i + 1] = temp;
                }
            }
        }

        SnapsEngine.SetTitleString("Contact Times");

        SnapsEngine.ClearTextDisplay();

        for (int position = 0; position < 5; position = position + 1)
        {
            if (contacts[position].ContactName == null)
            {
                break;
            }
            SnapsEngine.AddLineToTextDisplay(contacts[position].ContactName +
                                             ":" + contacts[position].ContactMinutesSpent);
        }

        SnapsEngine.WaitForButton("Continue");

        SnapsEngine.ClearTextDisplay();
    }
    public void StartProgram()
    {
        SnapsEngine.SetTitleString("Select Vehicle Type");

        int carsCount   = 0;
        int vansCount   = 0;
        int trucksCount = 0;
        int bikesCount  = 0;

        // repeatedly ask for pizza selections
        while (true)
        {
            string vehicleType = SnapsEngine.SelectFrom5Buttons(
                "Cars",
                "Vans",
                "Trucks",
                "Bikes",
                "Show Totals");

            if (vehicleType == "Cars")
            {
                carsCount = carsCount + 1;
            }

            if (vehicleType == "Vans")
            {
                vansCount = vansCount + 1;
            }

            if (vehicleType == "Trucks")
            {
                trucksCount = trucksCount + 1;
            }

            if (vehicleType == "Bikes")
            {
                bikesCount = bikesCount + 1;
            }

            if (vehicleType == "Show Totals")
            {
                SnapsEngine.ClearTextDisplay();

                SnapsEngine.AddLineToTextDisplay("Vehicle Totals");
                SnapsEngine.AddLineToTextDisplay(carsCount.ToString() +
                                                 " Cars");
                SnapsEngine.AddLineToTextDisplay(vansCount.ToString() +
                                                 " Vans");
                SnapsEngine.AddLineToTextDisplay(trucksCount.ToString() +
                                                 " Trucks");
                SnapsEngine.AddLineToTextDisplay(bikesCount.ToString() +
                                                 " Bikes");

                string reply = SnapsEngine.SelectFrom2Buttons(item1: "Done",
                                                              item2: "Reset");

                if (reply == "Reset")
                {
                    carsCount   = 0;
                    vansCount   = 0;
                    trucksCount = 0;
                    bikesCount  = 0;
                }
                // clear the total display from the screen ready for more choices
                SnapsEngine.ClearTextDisplay();
            }
        }
    }
    public void StartProgram()
    {
        SnapsEngine.SetTitleString("Select Pizza");

        int cheeseAndTomatoCount = 0;
        int pepperoniCount       = 0;
        int chickenCount         = 0;
        int vegetarianCount      = 0;

        // repeatedly ask for pizza selections

        while (true)
        {
            SnapsEngine.SpeakString("Tell me your choice:");

            string toppingChoice = SnapsEngine.SelectFromFiveSpokenPhrases(
                prompt: "What pizza topping do you want",
                phrase1: "Cheese and Tomato",
                phrase2: "Pepperoni",
                phrase3: "Chicken",
                phrase4: "Vegetarian",
                phrase5: "Show Totals");

            if (toppingChoice == "")
            {
                SnapsEngine.SpeakString("Sorry, choice not recognised");
                continue;
            }

            SnapsEngine.DisplayString(toppingChoice);

            if (toppingChoice == "Cheese and Tomato")
            {
                cheeseAndTomatoCount = cheeseAndTomatoCount + 1;
            }

            if (toppingChoice == "Pepperoni")
            {
                pepperoniCount = pepperoniCount + 1;
            }

            if (toppingChoice == "Chicken")
            {
                chickenCount = chickenCount + 1;
            }

            if (toppingChoice == "Vegetarian")
            {
                vegetarianCount = vegetarianCount + 1;
            }

            if (toppingChoice == "Show Totals")
            {
                SnapsEngine.DisplayString("Order Totals");

                SnapsEngine.AddLineToTextDisplay(cheeseAndTomatoCount.ToString() + " Cheese and Tomato");
                SnapsEngine.AddLineToTextDisplay(pepperoniCount.ToString() + " Pepperoni");
                SnapsEngine.AddLineToTextDisplay(chickenCount.ToString() + " Chicken");
                SnapsEngine.AddLineToTextDisplay(vegetarianCount.ToString() + " Vegetarian");

                string reply = SnapsEngine.SelectFrom2Buttons("Done", "Reset");
                if (reply == "Reset")
                {
                    cheeseAndTomatoCount = 0;
                    pepperoniCount       = 0;
                    chickenCount         = 0;
                    vegetarianCount      = 0;
                }
                // clear the total display from the screen
                SnapsEngine.ClearTextDisplay();
            }
        }
    }
    public void StartProgram()
    {
        while (true)
        {
            SnapsEngine.SetTitleString("Ice Cream Sales");

            // Find out how many sales values are being stored
            int   noOfStands = SnapsEngine.ReadInteger("How many ice cream stands");
            int[] sales      = new int[noOfStands];

            // Loop round and read the sales values
            for (int count = 0; count < sales.Length; count = count + 1)
            {
                // User likes to count from 1, not zero
                int displayCount = count + 1;
                sales[count] = SnapsEngine.ReadInteger("Enter the sales for stand " + displayCount);
            }

            while (true)
            {
                string command = SnapsEngine.SelectFrom6Buttons(
                    "Low to High",
                    "High to Low",
                    "Highest and Lowest",
                    "Total sales",
                    "Average sales",
                    "Enter figures");

                if (command == "Low to High")
                {
                    SnapsEngine.SetTitleString("Low to High Sales");

                    for (int pass = 0; pass < sales.Length - 1; pass = pass + 1)
                    {
                        // clear the swap flag for this pass
                        bool doneSwap = false;

                        // Make a pass down the array swapping elements
                        for (int i = 0; i < sales.Length - 1; i = i + 1)
                        {
                            if (sales[i] > sales[i + 1])
                            {
                                // the elements are in the wrong order, need to swap them round
                                int temp = sales[i];
                                sales[i]     = sales[i + 1];
                                sales[i + 1] = temp;
                                doneSwap     = true;
                            }
                        }
                        if (!doneSwap)
                        {
                            // quit the sort if we didn't do any swaps
                            break;
                        }
                    }

                    // Now print out the sorted data

                    SnapsEngine.ClearTextDisplay();

                    // Add a line to the string for each sales figure
                    for (int count = 0; count < sales.Length; count = count + 1)
                    {
                        SnapsEngine.AddLineToTextDisplay("Sales: " + sales[count]);
                    }

                    SnapsEngine.WaitForButton("Continue");
                    SnapsEngine.DisplayString("");
                }


                if (command == "High to Low")
                {
                    SnapsEngine.SetTitleString("High to Low Sales");

                    for (int pass = 0; pass < sales.Length - 1; pass = pass + 1)
                    {
                        // clear the swap flag for this pass
                        bool doneSwap = false;

                        // Make a pass down the array swapping elements
                        for (int i = 0; i < sales.Length - 1; i = i + 1)
                        {
                            if (sales[i] < sales[i + 1])
                            {
                                // the elements are in the wrong order, need to swap them round
                                int temp = sales[i];
                                sales[i]     = sales[i + 1];
                                sales[i + 1] = temp;
                                doneSwap     = true;
                            }
                        }
                        if (!doneSwap)
                        {
                            // quit the sort if we didn't do any swaps
                            break;
                        }
                    }

                    // Now print out the sorted data

                    SnapsEngine.ClearTextDisplay();

                    // Add a line to the string for each sales figure
                    for (int count = 0; count < sales.Length; count = count + 1)
                    {
                        SnapsEngine.AddLineToTextDisplay("Sales: " + sales[count]);
                    }

                    SnapsEngine.WaitForButton("Continue");
                    SnapsEngine.DisplayString("");
                }

                if (command == "Highest and Lowest")
                {
                    SnapsEngine.SetTitleString("Highest and Lowest");

                    int highest = sales[0];
                    int lowest  = sales[0];
                    foreach (int sale in sales)
                    {
                        if (sale > highest)
                        {
                            highest = sale;
                        }
                        if (sale < lowest)
                        {
                            lowest = sale;
                        }
                    }

                    SnapsEngine.DisplayString("Highest " + highest + "\n" +
                                              "Lowest " + lowest);

                    SnapsEngine.WaitForButton("Continue");
                    SnapsEngine.DisplayString("");
                }

                if (command == "Total sales")
                {
                    SnapsEngine.SetTitleString("Total Sales");

                    int totalSales = 0;
                    foreach (int sale in sales)
                    {
                        totalSales = totalSales + sale;
                    }

                    SnapsEngine.DisplayString("Total sales " + totalSales);

                    SnapsEngine.WaitForButton("Continue");
                    SnapsEngine.DisplayString("");
                }

                if (command == "Average sales")
                {
                    SnapsEngine.SetTitleString("Average sales");

                    int total = 0;
                    foreach (int sale in sales)
                    {
                        total = total + sale;
                    }

                    float average = (float)total / sales.Length;

                    SnapsEngine.DisplayString("Average sales " + average);

                    SnapsEngine.WaitForButton("Continue");
                    SnapsEngine.DisplayString("");
                }

                if (command == "Enter figures")
                {
                    SnapsEngine.SetTitleString("Enter New Data");

                    string confirm = SnapsEngine.SelectFrom2Buttons("Enter new data", "Cancel");

                    if (confirm == "Enter new data")
                    {
                        break;
                    }
                }
            }
        }
    }
示例#25
0
    public void StartProgram()
    {
        SnapsEngine.SetTitleString("What kind of pizza?!");
        // variables that count pizza types
        int pepperoni = 0;
        int cheese    = 0;
        int beef      = 0;
        int supreme   = 0;
        // counter variable for loop
        int counter = 1;

        // loop around 4 times unless overview is clicked
        while (counter <= 4)
        {
            {
                // asks user to say favorite pizza or overview
                string toppingChoice = SnapsEngine.SelectFromFiveSpokenPhrases(prompt: "What's your favorite pizza?", phrase1: "Pepperoni", phrase2: "Cheese", phrase3: "Supreme", phrase4: "Beef", phrase5: "Overview");
                // adds one to whatever pizza user chose
                if (toppingChoice == "Pepperoni")
                {
                    pepperoni = pepperoni + 1;
                }
                if (toppingChoice == "Cheese")
                {
                    cheese = cheese + 1;
                }
                if (toppingChoice == "Beef")
                {
                    beef = beef + 1;
                }
                if (toppingChoice == "Supreme")
                {
                    supreme = supreme + 1;
                }

                // if user selects overview, it will display and say what choices he/she chose
                if (toppingChoice == "Overview")
                {
                    SnapsEngine.ClearTextDisplay();
                    SnapsEngine.SpeakString("There were " + pepperoni + " pepperoni pizzas");
                    SnapsEngine.AddLineToTextDisplay("There were " + pepperoni + " pepperoni pizzas");
                    SnapsEngine.Delay(3);
                    SnapsEngine.SpeakString("There were " + cheese + " cheese pizzas");
                    SnapsEngine.AddLineToTextDisplay("There were " + cheese + " cheese pizzas");
                    SnapsEngine.Delay(3);
                    SnapsEngine.SpeakString("There were " + beef + " beef pizzas");
                    SnapsEngine.AddLineToTextDisplay("There were " + beef + " beef pizzas");
                    SnapsEngine.Delay(3);
                    SnapsEngine.SpeakString("There were " + supreme + " supreme pizzas");
                    SnapsEngine.AddLineToTextDisplay("There were " + supreme + " supreme pizzas");
                    SnapsEngine.Delay(3);
                    // exits loop
                    break;
                }
                // if no logical selection has been chosen, alerts users of error and repeats the prompt
                else
                {
                    SnapsEngine.SpeakString("Sorry that is not a viable selection!");
                    continue;
                }


                counter = counter + 1;
            }
        }
        // if user says 4 pizza choices, this block runs. its an overview without clicking on it after max 4 choices
        SnapsEngine.ClearTextDisplay();
        SnapsEngine.SpeakString("There were " + pepperoni + " pepperoni pizzas");
        SnapsEngine.AddLineToTextDisplay("There were " + pepperoni + " pepperoni pizzas");
        SnapsEngine.Delay(3);
        SnapsEngine.SpeakString("There were " + cheese + " cheese pizzas");
        SnapsEngine.AddLineToTextDisplay("There were " + cheese + " cheese pizzas");
        SnapsEngine.Delay(3);
        SnapsEngine.SpeakString("There were " + beef + " beef pizzas");
        SnapsEngine.AddLineToTextDisplay("There were " + beef + " beef pizzas");
        SnapsEngine.Delay(3);
        SnapsEngine.SpeakString("There were " + supreme + " supreme pizzas");
        SnapsEngine.AddLineToTextDisplay("There were " + supreme + " supreme pizzas");
        SnapsEngine.Delay(3);
    }
    public void StartProgram()
    {
        SnapsEngine.SetTitleString("Select Pizza");

        int cheeseAndTomatoCount = 0;
        int pepperoniCount       = 0;
        int chickenCount         = 0;
        int vegetarianCount      = 0;

        // repeatedly ask for pizza selections
        while (true)
        {
            string toppingChoice = SnapsEngine.SelectFrom5Buttons(
                "Cheese and Tomato",
                "Pepperoni",
                "Chicken",
                "Vegetarian",
                "Show Totals");

            if (toppingChoice == "Cheese and Tomato")
            {
                cheeseAndTomatoCount = cheeseAndTomatoCount + 1;
            }

            if (toppingChoice == "Pepperoni")
            {
                pepperoniCount = pepperoniCount + 1;
            }

            if (toppingChoice == "Chicken")
            {
                chickenCount = chickenCount + 1;
            }

            if (toppingChoice == "Vegetarian")
            {
                vegetarianCount = vegetarianCount + 1;
            }

            if (toppingChoice == "Show Totals")
            {
                SnapsEngine.ClearTextDisplay();

                SnapsEngine.AddLineToTextDisplay("Order Totals");
                SnapsEngine.AddLineToTextDisplay(cheeseAndTomatoCount.ToString() + " Cheese and Tomato");
                SnapsEngine.AddLineToTextDisplay(pepperoniCount.ToString() + " Pepperoni");
                SnapsEngine.AddLineToTextDisplay(chickenCount.ToString() + " Chicken");
                SnapsEngine.AddLineToTextDisplay(vegetarianCount.ToString() + " Vegetarian");

                string reply = SnapsEngine.SelectFrom2Buttons(item1: "Done", item2: "Reset");

                if (reply == "Reset")
                {
                    cheeseAndTomatoCount = 0;
                    pepperoniCount       = 0;
                    chickenCount         = 0;
                    vegetarianCount      = 0;
                }

                // clear the total display from the screen ready for more choices
                SnapsEngine.ClearTextDisplay();
            }
        }
    }
示例#27
0
    public void StartProgram()
    {
        SnapsEngine.SetTitleColor(red: 255, green: 255, blue: 255);

        SnapsEngine.SetTitleString("Select Pizza");
        SnapsEngine.DisplayBackground(imageURL: "https://images7.alphacoders.com/429/thumb-1920-429071.jpg");

        int cheeseAndTomatoCount = 0;
        int pepperoniCount       = 0;
        int chickenCount         = 0;
        int vegetarianCount      = 0;

        // repeatedly ask for pizza selections
        while (true)
        {
            string toppingChoice = SnapsEngine.SelectFrom5Buttons(
                "Cheese and Tomato",
                "Pepperoni",
                "Chicken",
                "Vegetarian",
                "Show Totals");

            if (toppingChoice == "Cheese and Tomato")
            {
                cheeseAndTomatoCount = cheeseAndTomatoCount + 1;
            }

            if (toppingChoice == "Pepperoni")
            {
                pepperoniCount = pepperoniCount + 1;
            }

            if (toppingChoice == "Chicken")
            {
                chickenCount = chickenCount + 1;
            }

            if (toppingChoice == "Vegetarian")
            {
                vegetarianCount = vegetarianCount + 1;
            }

            if (toppingChoice == "Show Totals")
            {
                SnapsEngine.ClearTextDisplay();

                SnapsEngine.AddLineToTextDisplay("Order Totals");
                SnapsEngine.AddLineToTextDisplay(cheeseAndTomatoCount.ToString() + " Cheese and Tomato");
                SnapsEngine.AddLineToTextDisplay(pepperoniCount.ToString() + " Pepperoni");
                SnapsEngine.AddLineToTextDisplay(chickenCount.ToString() + " Chicken");
                SnapsEngine.AddLineToTextDisplay(vegetarianCount.ToString() + " Vegetarian");

                string reply = SnapsEngine.SelectFrom2Buttons(item1: "Done", item2: "Reset");

                if (reply == "Reset")
                {
                    cheeseAndTomatoCount = 0;
                    pepperoniCount       = 0;
                    chickenCount         = 0;
                    vegetarianCount      = 0;
                }

                // clear the total display from the screen ready for more choices
                SnapsEngine.ClearTextDisplay();
            }
        }
    }