public IActionResult Show(int rideId)
        {
            ViewBag.ApiKey = "https://maps.googleapis.com/maps/api/js?key=AIzaSyDr42YUsPp9WhD8eoNWXJBpS85Epc0F-xw&callback=myMap";
            ride rideinfo = dbContext.rides.Include(w => w.comments).FirstOrDefault(w => w.rideId == rideId);

            return(View(rideinfo));
        }
        public IActionResult Destroy(int rideId)
        {
            ride remove = dbContext.rides.FirstOrDefault(w => w.rideId == rideId);

            dbContext.rides.Remove(remove);
            dbContext.SaveChanges();
            return(RedirectToAction("Dashboard"));
        }
Exemple #3
0
    public int timeRemaining;   //number of ticks left

    static void Main()
    {
        int currentTime   = 0;              //current tick, initialised to 0
        int availableCars = 0;              //number of cars not on rides

        ride[] rides         = new ride[1]; //array of rides
        car[]  cars          = new car[1];  //array of cars
        int    bonus         = 0;           //number of bonus points for being early
        int    timeRemaining = 0;           //number of ticks left

        readIn(ref availableCars, ref rides, ref cars, ref bonus, ref timeRemaining);
    }
 public IActionResult Create(ride plan)
 {
     if (ModelState.IsValid)
     {
         dbContext.rides.Add(plan);
         dbContext.SaveChanges();
         return(Redirect($"show/{plan.rideId}"));
     }
     else
     {
         return(View("NewInfo"));
     }
 }
Exemple #5
0
    public void advance()
    {
        //advance 1 tick
        while (timeRemaining > 0)
        {
            for (int i = 0; i < cars.Length; i++)
            {
                car Car = cars[i];
                Car.move();
            }

            for (int i = 0; i < rides.Length; i++)
            {
                ride Ride = ride[i];
                if (!Ride.complete && !Ride.inCar && Ride.earliestStart <= currentTime)
                {
                    //find free cars
                    car nearestCar;
                    for (int j = 0; j < cars.Length; j++)
                    {
                        car Car = cars[j];
                        if (!Car.busy)
                        {
                            if (nearestCar == null || Distance(nearestCar, Ride.start) > Distance(Car, Ride.start))
                            {
                                nearestCar = Car;
                            }
                            if (Distance(nearestCar, Ride) == 0)
                            {
                                Ride.inCar      = true;
                                nearestCar.busy = true;
                                Car.destination = Ride.end;
                                Car.Ride        = Ride;
                                break;
                            }
                        }
                    }
                    if (nearestCar != null)
                    {
                        Car.destination = Ride.start;
                    }
                }
            }
            currentTime++;
            timeRemaining--;
        }
    }
Exemple #6
0
 static void readIn(ref int availableCars, ref ride[] rides, ref car[] cars, ref int bonus, ref int timeRemaining)      //read data in from the .in file
 {
     string[] file        = System.IO.File.ReadAllLines(files[0]);
     string[] currentLine = file[0].Split(' ');
     availableCars = Int32.Parse(currentLine[2]);
     cars          = new car[Int32.Parse(currentLine[2])];
     rides         = new ride[Int32.Parse(currentLine[3])];
     bonus         = Int32.Parse(currentLine[4]);
     timeRemaining = Int32.Parse(currentLine[5]);
     for (int i = 1; i < file.Length; i++)
     {
         currentLine        = file[i].Split(' ');
         rides[i - 1]       = new ride();
         rides[i - 1].start = new int[2] {
             Int32.Parse(currentLine[0]), Int32.Parse(currentLine[1])
         };
         rides[i - 1].end = new int[2] {
             Int32.Parse(currentLine[2]), Int32.Parse(currentLine[3])
         };
         rides[i - 1].earliestStart = Int32.Parse(currentLine[4]);
         rides[i - 1].latestFinish  = Int32.Parse(currentLine[5]);
         //Console.WriteLine("Ride added. Start: {0}, End: {1}, Earliest Start: {2}, Latest Finish: {3}", rides[i-1].start, rides[i-1].end, rides[i-1].earliestStart, rides[i-1].latestFinish);
     }
 }