dimanche 9 août 2015

how do make an array that doesnt call random characters

When ever the user types in inventory I want the user to be able to sort through their inventory and possibly call it as a function for further use. I also want the user to be able to use the item and have the item have a set value.

This is my code:

 using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


namespace game1
{
    class Program
    {
        static void Main(string[] args)
        {
            //integers
            int stock = 0;
            int countarray;

            //strings
            string game;
            string[] item = new string[3];
            string input;
            //string item0;
            //string item1;
            //tring item2;

            do { 
                Console.Clear();
                Console.WriteLine("does the user want to play");
                Console.WriteLine("press 'y' for yes 'n' for no");
                game = Console.ReadLine();

                if (game == "y")
                {
                    stock = 1;
                    //Console.ReadLine();
                    Console.WriteLine("welcome");
                }
                if (game == "n")
                {
                    stock = 0;
                }
                else if(game!= "n"){
                    stock = 0;

                }



            } while (stock == 0);
            stock = 0;


            //inventoryppp
            item[0] = "pocketknife";
            item[1] = "match";
            item[2] = "spear";

            Console.Clear();
            Console.WriteLine("inventory test");
            input = Console.ReadLine();
            //inventory logic

            if (input == "inventory")
            {
                Console.Clear();
                Console.WriteLine("Players Inventory");
                for (countarray = 0; countarray < 3; countarray++)
                {

                    int Write_position = 0;
                    Write_position = Write_position + countarray;
                    Console.SetCursorPosition(0, countarray);
                    Console.WriteLine("{0}", item[countarray]);

                }
            }
            else
            {

            }
            Console.ReadLine();

        }
    }
}

Aucun commentaire:

Enregistrer un commentaire