예제 #1
0
        void returnScooters()
        {
            Console.WriteLine();
            Console.WriteLine("RETURN SCOOTERS...");

            try
            {
                service.login("user1", "user1");
                Station st    = service.findStationById("st2");
                User    us    = service.userLogged();
                Rental  r     = us.lastRental();
                decimal price = service.returnScooter(r, st);
            }
            catch (Exception e)
            {
                printError(e);
            }
            service.logout();

            try
            {
                service.login("user1", "user1");
                Station st    = service.findStationById("st2");
                User    us    = service.userLogged();
                Rental  r     = us.lastRental();
                decimal price = service.returnScooter(r, st);
            }
            catch (Exception e)
            {
                printError(e);
            }
            service.logout();

            try
            {
                service.login("user5", "user5");
                Station st    = service.findStationById("st3");
                User    us    = service.userLogged();
                Rental  r     = us.lastRental();
                decimal price = service.returnScooter(r, st);
            }
            catch (Exception e)
            {
                printError(e);
            }
            service.logout();

            try
            {
                service.login("user6", "user6");
                Station  st = service.findStationById("st4");
                User     us = service.userLogged();
                Rental   r  = us.lastRental();
                Incident i  = new Incident("Crash with a mobile streetlamp", DateTime.Now);
                r.addIncident(i);
                decimal price = service.returnScooter(r, st);
            }
            catch (Exception e)
            {
                printError(e);
            }
            service.logout();

            foreach (Rental r in service.getAllRentals())
            {
                Console.WriteLine(rentalToString(r));
                if (r.Incident != null)
                {
                    Console.WriteLine("      " + r.Incident.Description + " time: " + r.Incident.TimeStamp);
                }
            }
        }