public string SessionTypeTest([PexAssumeUnderTest] User target, IBookable bookable) { string result = target.SessionType(bookable); return(result); // TODO: add assertions to method UserTest.SessionTypeTest(User, IBookable) }
/// <summary> /// implementing the IBookable interface, tally up the cost /// </summary> /// <param name="bookable">object of the IBookable interface</param> public string BookItem(IBookable bookable) { //declare variable to store output message String msg; //calculate running total and run function "bookable" will be for example Gym or PersonalTrainer etc depending on what is being passed in runningCost = runningCost + bookable.Price; bookable.BookSession(); //create message and write to the screen msg = "Booked @ " + bookable.Price + "\nSubtotal = " + runningCost; return(msg); }
/// <summary> /// Book a session for the user and tally cost /// </summary> /// <param name="bookable">Bookable session</param> /// <returns>string confirming the amount to now be paid and what has just been booked</returns> public string SessionType(IBookable bookable) { //create a string variable to return string msg; //test to see what class the bookable session is within if (bookable is Gym) { //check if this is a subclass if (bookable is GymWithPool) { msg = bookable.ToString() + " is a gym with a pool."; return(msg); } else { msg = bookable.ToString() + " is a Gym."; return(msg); } } //repeat procedure for each class and sub class else if (bookable is Classes) { if (bookable is YogaClass) { msg = bookable.ToString() + " is a Yoga class."; return(msg); } else { msg = bookable.ToString() + " is a Boxing class."; return(msg); } } else if (bookable is PersonalTrainer) { msg = bookable.ToString() + " is a Personal Trainer session."; return(msg); } else { msg = bookable.ToString() + " is an unknown sale type."; return(msg); } }