Example #1
0
	// Update is called once per frame
	public void PowerType (int pType, GameObject powerUp) {
		
		choice = (choices)pType;
			switch(choice)
			{
			case choices.Immune: 
				//add whatever to powerup go, or have each state its own class.
				Debug.Log("Immune");
				break;
			case choices.Speed:
				Debug.Log("Speed");
				break;
			case choices.Invisible:
				Debug.Log("Invisible");
				break;
			default:
				Debug.Log("Nothing");
				break;
			}
	}
Example #2
0
	// Use this for initialization
	void Start () {
		choice = choices.None;
	}
        /// <summary>
        /// Main
        /// </summary>
        static void Main(string[] args)
        {
            List <LineStation>  stationsData = setStationsList();
            BusesLineCollection linesData    = setBusLinecollection(stationsData);

            double  lineNumber;
            double  StationKey;
            int     areaNumber;
            double  firstStationKey;
            double  secondStationKey;
            bool    flag   = false;
            choices choice = choices.addBus; // Reset.

            while (choice != 0)
            {
                Console.WriteLine("What is your request?\n" +
                                  "(0) Exit\n" +
                                  "(1) Add a bus line\n" +
                                  "(2) Add a line station\n" +
                                  "(3) Remove a bus line\n" +
                                  "(4) Remove a line station\n" +
                                  "(5) Search all lines passing through a station\n" +
                                  "(6) Find shortest rode between 2 stations\n" +
                                  "(7) Display all bus lines\n" +
                                  "(8) Display all stations and their bus lines\n");
                choices.TryParse(Console.ReadLine(), out choice);
                try
                {
                    switch (choice)
                    {
                    case choices.addBus:     // Add a bus line.
                        Console.WriteLine("Please enter new bus line.");
                        double.TryParse(Console.ReadLine(), out lineNumber);
                        Console.WriteLine("Please enter line area.\n" +
                                          "(0) Jerusalem\n" + "(1) Har_Nof\n" + "(2) Givat_Shaul\n");
                        int.TryParse(Console.ReadLine(), out areaNumber);
                        Console.WriteLine("Please enter first station.");
                        double.TryParse(Console.ReadLine(), out firstStationKey);
                        Console.WriteLine("Please enter last station.");
                        double.TryParse(Console.ReadLine(), out secondStationKey);
                        bool        flag1         = false;
                        bool        flag2         = false;
                        LineStation firstStation  = new LineStation();
                        LineStation secondStation = new LineStation();
                        foreach (LineStation station in stationsData)
                        {
                            if (station.BusStationKey == firstStationKey)
                            {     // The first station found in data.
                                firstStation = station;
                                flag1        = true;
                            }
                            if (station.BusStationKey == secondStationKey)
                            {     // The second station found in data.
                                flag2         = true;
                                secondStation = station;
                            }
                        }
                        if (flag1 && flag2)
                        {                               // Checks if both stations found.
                            BusesLine newLine = new BusesLine(lineNumber, firstStation, secondStation, areaNumber);
                            linesData.addLine(newLine); // Adds line to data.
                        }
                        else                            // If one station or more not found
                        {
                            throw new myException("One or more of the stations not exist!");
                        }
                        break;

                    case choices.addStation:     // Add a line station.
                        Console.WriteLine("Please enter bus line which you'd like to add a new station.");
                        double.TryParse(Console.ReadLine(), out lineNumber);
                        flag = false;
                        foreach (BusesLine line in linesData)
                        {
                            if (line.BusLine == lineNumber)
                            {     // Wanted line found.
                                Console.WriteLine("Please enter wanted station.");
                                double.TryParse(Console.ReadLine(), out StationKey);
                                foreach (LineStation station in stationsData)
                                {
                                    if (station.BusStationKey == StationKey)
                                    {     // Check if station exists in data.
                                        line.addStation(station);
                                        flag = true;
                                        break;
                                    }
                                }
                            }
                        }
                        if (!flag)     // Line not exists in data.
                        {
                            throw new myException("Line not exist!");
                        }
                        break;

                    case choices.removeBus:     // Remove a bus line.
                        Console.WriteLine("Please enter bus line which you'd like to remove.");
                        double.TryParse(Console.ReadLine(), out lineNumber);
                        foreach (BusesLine line in linesData)
                        {                                   // Checks if line exists in data.
                            if (line.BusLine == lineNumber) // Wanted line found.
                            {
                                linesData.removeLine(line);
                            }
                        }
                        break;

                    case choices.RemoveStation:     // Remove a line station.
                        Console.WriteLine("Please enter bus line which you'd like to remove a existed station.");
                        double.TryParse(Console.ReadLine(), out lineNumber);
                        flag = false;
                        foreach (BusesLine line in linesData)
                        {
                            if (line.BusLine == lineNumber)
                            {     // Checks line exists in data.
                                Console.WriteLine("Please enter wanted station.");
                                double.TryParse(Console.ReadLine(), out StationKey);
                                foreach (LineStation station in stationsData)
                                {
                                    if (station.BusStationKey == StationKey)
                                    {     // Wanted station found.
                                        line.removeStation(station);
                                        flag = true;
                                        break;
                                    }
                                }
                            }
                        }
                        if (!flag)     // Station not exist in data.
                        {
                            throw new myException("Station not exist!");
                        }
                        break;

                    case choices.searchByStation:     // Search all lines passing through a station.
                        Console.WriteLine("Please enter wanted station.");
                        double.TryParse(Console.ReadLine(), out StationKey);
                        flag = false;
                        foreach (LineStation station in stationsData)
                        {
                            if (station.BusStationKey == StationKey)
                            {     // Checks if station exist in data.
                                flag = true;
                                break;
                            }
                        }
                        if (!flag)     // if station not exist in data.
                        {
                            throw new myException("Station not exist!");
                        }
                        flag = false;
                        Console.WriteLine("Lines passing through station " + StationKey + ":\n");
                        List <BusesLine> stationLines = new List <BusesLine>(linesData.allBusesForStation(StationKey));
                        foreach (BusesLine line in stationLines)
                        {     // Prints lines.
                            Console.WriteLine("Line number: " + line.BusLine.ToString());
                        }
                        if (!stationLines.Any())     // If no line passing through the station.
                        {
                            throw new myException("No lines found.");
                        }
                        break;

                    case choices.busTime:     // Find shortest rode between 2 stations.
                        Console.WriteLine("Please enter departure station:\n");
                        double.TryParse(Console.ReadLine(), out firstStationKey);
                        Console.WriteLine("Please enter destination station:\n");
                        double.TryParse(Console.ReadLine(), out secondStationKey);
                        flag1         = false;
                        flag2         = false;
                        firstStation  = new LineStation();
                        secondStation = new LineStation();
                        foreach (LineStation station in stationsData)
                        {
                            if (station.BusStationKey == firstStationKey)
                            {     // First station found in data.
                                firstStation = station;
                                flag1        = true;
                            }
                            if (station.BusStationKey == secondStationKey)
                            {     // Last station found in data.
                                secondStation = station;
                                flag2         = true;
                            }

                            if (flag1 && flag2)     // If both stations found in data.
                            {
                                break;
                            }
                        }
                        if (!flag1 || !flag2)     // If one of the stations or more not exists in data.
                        {
                            throw new myException("One or more of the stations not exist!");
                        }

                        if (firstStation.BusStationKey == secondStation.BusStationKey)
                        {
                            // If first and last stations are the same.
                            throw new myException("Stations are the same. There's no rode exist!");
                        }
                        BusesLineCollection subLineCollection = new BusesLineCollection();
                        // Create a collection of all lines which fassing through both stations:
                        foreach (BusesLine line in linesData)
                        {
                            if (line.search(firstStationKey) && line.search(secondStationKey))
                            {
                                // Checks if both stations are on the same rode.
                                subLineCollection.addLine(line.subBusLine(firstStation, secondStation));
                            }
                        }
                        BusesLineCollection collectionToPrint = new BusesLineCollection(new ObservableCollection <BusesLine>
                                                                                            (subLineCollection.sortAllBuses().Distinct()));
                        // Prints results:
                        print(collectionToPrint, false);
                        break;

                    case choices.allBuses:     // Display all bus lines.
                        Console.WriteLine("All buses exist list:\n");
                        print(linesData, true);
                        break;

                    case choices.allStation:     // Display all stations and their bus lines.
                        Console.WriteLine("All stations and their buses list:\n");
                        foreach (LineStation station in stationsData)
                        {
                            Console.WriteLine(station.ToString());
                            foreach (BusesLine line in linesData)
                            {
                                if (line.search(station.BusStationKey))
                                {
                                    // Checks if line is passing through station.
                                    Console.WriteLine("Line: " + line.BusLine + "\n");
                                }
                            }
                        }
                        break;

                    case choices.exit:     // Exit.
                        Console.WriteLine("Bye!\n");
                        break;

                    default:
                        Console.WriteLine("Illegal input! Try again.\n");
                        break;
                    }
                }
                catch (myException newException)
                {
                    Console.WriteLine(newException.ToString());
                }
            }
        }
Example #4
0
 Exchanges         = new SelectList(choices, nameof(chosen.Value), nameof(chosen.Name), chosen);
Example #5
0
 public void SophiaSelected()
 {
     Charenum = choices.sophia;
 }
Example #6
0
 public void KazuSelected()
 {
     Charenum = choices.Kazu;
 }
        public ActionResult QuestionIterator(SelectedPaper result)
        {
            if (Session["usercookie"] == null)
            {
                return(RedirectToAction("Authenticate", "Users"));
            }
            else
            {
                if (result.CourseId != 0 && result.levelId != 0 && result.paperId != 0)
                {
                    DBEntities dbContext = new DBEntities();
                    if (Session["SelectedCourse"] == null && Session["SelectedPaper"] == null && Session["SelectedLevel"] == null && Session["SelectedCourse"] == null)
                    {
                        Session["SelectedCourse"] = (from c in dbContext.Courses where c.CourseId == result.CourseId select c).ToList().FirstOrDefault();
                        Session["SelectedPaper"]  = (from p in dbContext.Papers where p.PaperId == result.paperId select p).ToList().FirstOrDefault();
                        Session["SelectedLevel"]  = (from l in dbContext.Levels where l.Level == result.levelId select l).ToList().FirstOrDefault();
                    }

                    if (Session["TestId"] == null)
                    {
                        Session["TestId"] = Guid.NewGuid(); //create testId for new test
                    }
                    Users   usercookie     = Session["usercookie"] as Users;
                    Courses SelectedCourse = Session["SelectedCourse"] as Courses;
                    Papers  SelectedPaper  = Session["SelectedPaper"] as Papers;
                    Levels  SelectedLevel  = Session["SelectedLevel"] as Levels;
                    Guid    TestId         = new Guid(Session["TestId"].ToString());

                    var questions = dbContext.GetQuestions(SelectedCourse.CourseId, SelectedPaper.PaperId, usercookie.Id, SelectedLevel.Level).ToList();
                    if (questions.Count > 0)
                    {
                        List <GetQuestions_Result> QuestionList = new List <GetQuestions_Result>();
                        int outercount = 0;
                        int innercount = 0;
                        while (true)
                        {
                            if (outercount >= questions.Count)
                            {
                                break;
                            }
                            GetQuestions_Result outernode = questions[outercount];
                            int QId = outernode.QId;
                            innercount = 0;
                            GetQuestions_Result FinalQuestion = new GetQuestions_Result();
                            FinalQuestion.QId        = outernode.QId;
                            FinalQuestion.PaperId    = outernode.PaperId;
                            FinalQuestion.CourseId   = outernode.CourseId;
                            FinalQuestion.Question   = outernode.Question;
                            FinalQuestion.Duration   = outernode.Duration;
                            FinalQuestion.OptionType = outernode.OptionType;
                            List <choices> choicelist = new List <choices>();
                            foreach (GetQuestions_Result innernode in questions)
                            {
                                choices choice = new choices();
                                if (QId == innernode.QId)
                                {
                                    choice.Comprehensive = "";
                                    choice.choiceId      = innernode.OptionId;
                                    choice.choiceText    = innernode.OptionText;
                                    choicelist.Add(choice);
                                    innercount++;
                                }
                                else
                                {
                                    continue;
                                }
                            }
                            FinalQuestion.options = choicelist;
                            QuestionList.Add(FinalQuestion);
                            outercount = outercount + innercount;
                        }
                        return(View(RandomizeQuestions(QuestionList)));
                    }
                    else
                    {
                        return(RedirectToAction("CalculateScore"));
                    }
                }
                else
                {
                    ViewData["MSG"] = "Please select valid options to proceed.";
                    return(RedirectToAction("GetCourse"));
                }
            }
        }
        static void Main(string[] args)
        {
            List <Bus> busList = new List <Bus>();
            choices    choice  = choices.add; // Reset.
            string     licenseNumber;
            DateTime   date;

            while (choice != 0)
            {
                Console.WriteLine("What is your request?\n" +
                                  "(0) Exit\n" +
                                  "(1) Add a bus\n" +
                                  "(2) Select a ride\n" +
                                  "(3) Operations: refuel or make a treatment\n" +
                                  "(4) Display bus license number and its kilometer data for all buses");
                choices.TryParse(Console.ReadLine(), out choice);
                switch (choice)
                {
                case choices.add:     // Add a new bus to data.
                    Console.WriteLine("Please enter new bus license number.");
                    licenseNumber = Console.ReadLine();
                    if (licenseNumber.Length != 7 && licenseNumber.Length != 8)
                    {     // Check if license Number format legal.
                        Console.WriteLine("License Number format illegal");
                        break;
                    }
                    Console.WriteLine("Please enter the new bus start date in format dd/mm/yy.");
                    date = Convert.ToDateTime(Console.ReadLine());
                    Bus newBus = new Bus(licenseNumber, date);
                    busList.Add(newBus);
                    break;

                case choices.select:     // Select ride.
                    Console.WriteLine("Please enter wished bus license number.");
                    licenseNumber = Console.ReadLine();
                    foreach (Bus myBus in busList)
                    {
                        if (myBus.getLicenseNumber() == licenseNumber)
                        {     // Check if the bus exists.
                            Random r      = new Random(DateTime.Now.Millisecond);
                            double ride   = r.Next(0, 1200);
                            int    result = myBus.integrityCheck(ride);

                            if (result == 1)     // There's not enough fuel for the ride.
                            {
                                Console.WriteLine("There's not enough fuel for the ride. " +
                                                  "Please refuel.");
                            }
                            if (result == 2)     // The bus needs treatment.
                            {
                                Console.WriteLine("It's been a year and the bus needs treatment. " +
                                                  "Please send for treatment.");
                            }
                        }
                        else
                        {
                            Console.WriteLine("The viacle's not found. Try again.");
                        }
                    }
                    break;

                case choices.operations:     // Refuel or make a treatment.
                    Console.WriteLine("Please enter wished bus license number.");
                    licenseNumber = Console.ReadLine();
                    foreach (Bus myBus in busList)
                    {
                        if (myBus.getLicenseNumber() == licenseNumber)
                        {     // Check if the bus exists.
                            Console.WriteLine("Please enter the wished operation. (1) for refuel. (2) for treatment.");
                            int op = int.Parse(Console.ReadLine());
                            if (op == 1)    // Refuel.
                            {
                                myBus.afterRefueling();
                            }
                            else if (op == 2)     // Make a treatment.
                            {
                                myBus.afterTreatment();
                            }
                        }
                        else
                        {
                            Console.WriteLine("The viacle's not found. Try again.");
                        }
                    }
                    break;

                case choices.display:     // Display bus license number and its
                    // kilometer data for all buses.
                    foreach (Bus myBus in busList)
                    {
                        Console.WriteLine("Viacle:");
                        printlicenseNumberForm(myBus.getLicenseNumber());
                        Console.WriteLine("Kilometer:\n" + myBus.gettotalKilometers());
                    }
                    break;

                case choices.exit:
                    Console.WriteLine("Bye!");
                    break;

                default:
                    break;
                }
            }
        }
Example #9
0
        static void Main(string[] args)
        {
            choices choice = choices.def;

            string[] tokens;

            MyMatrix matr1, matr2, matr3;

            while (choice != choices.exit)
            {
                Console.WriteLine("Hey, please enter size for new matrix ");

                tokens = Console.ReadLine().Split();

                matr1 = new MyMatrix(int.Parse(tokens[0]), int.Parse(tokens[1]));
                Console.WriteLine("\nGreat. whatcha wanna do? 'a' for add, 'm' for multiplication, 'f' for fill, 'p' for print, 'i' for init, 'r' for fillrandom, 'f' to fill in from input, or 'x' to exit, and 'c' to cancel " +
                                  "working on a matrix ");
                while (choice != choices.cancel)
                {
                    choice = (choices)Console.ReadKey().KeyChar;
                    switch (choice)
                    {
                    case choices.print:
                        matr1.Print();
                        break;

                    case choices.init:
                        matr1.Init();
                        break;

                    case choices.fillrandom:
                        matr1.FillRandom();
                        break;

                    case choices.input:
                        matr1.Input();
                        break;

                    case choices.addition:
                    {
                        matr2 = new MyMatrix(matr1.X, matr1.Y);
                        matr2.Init();
                        Console.WriteLine("Great. Please enter how you wanna fill that other matrix. f for regular input, r for random");
                        if (Console.ReadKey().KeyChar == 'f')
                        {
                            matr2.Input();
                            matr3 = matr1.Add(matr2);
                            matr3.Print();
                        }
                        else if (Console.ReadKey().KeyChar == 'r')
                        {
                            matr2.FillRandom();
                            matr3 = matr1.Add(matr2);
                            matr3.Print();
                        }
                        else
                        {
                            Console.WriteLine("Well darn. that didn't work;");
                        }
                    }
                    break;

                    case choices.multiply:
                        Console.WriteLine("how large should that other one be? one num please");

                        matr2 = new MyMatrix(int.Parse(Console.ReadLine().Split()[0]), matr1.Y);
                        matr2.Init();
                        Console.WriteLine("Great. Please enter how you wanna fill that other matrix. f for regular input, r for random");
                        if (Console.ReadKey().KeyChar == 'f')
                        {
                            matr2.Input();
                            matr3 = matr1.Mult(matr2);
                            matr3.Print();
                        }
                        else if (Console.ReadKey().KeyChar == 'r')
                        {
                            matr2.FillRandom();
                            matr3 = matr1.Mult(matr2);
                            matr3.Print();
                        }
                        else
                        {
                            Console.WriteLine("Well darn. that didn't work;");
                        }
                        break;

                    default:
                        break;
                    }
                }
            }
        }