100 Days of Code Day 14 - MORE PYTHON! :)

Hello! My name is Rick and I am in search for gig as a developer :)

This past December I finished up a year long study with a full-stack school in NYC called Codeimmersives. We explored HTML, CSS, JavaScript, and how to build applications using the MERN stack. I learned about class-based components, passing props around (prop-drilling) and utilizing the component lifecycle(componentWillMount, componentDidMount, etc). After learning class based components, we moved on to functional based components using hooks, custom hooks, and different ways to manage state, such as the useContext and Redux APIs. (This is just a brief overview of the technologies I studied over the past year). Currently I am enrolled at devCodeCamp learning the basics of Python. I am documenting my journey by sharing these blog posts. Please help me out by dropping a comment below on what you think!

Today was a pretty good day. I was able to fit my time at the gym, cook steak and shrimp fried rice, listen to lectures on loops in python then code out this problem below....almost complete but I'll probably edit this post tomorrow after I add the final touches on my solution. (Today was cold and rainy)

DAY TRIP GENERATOR

Learning Objective

Use and practice Python fundamentals, with an emphasis on Single Responsibility.

Technologies

Python

User Stories

Total Unweighted Project Points: /70

Total Weighted Project Points: /10

  • (5 points): As a developer, I want to make at least three commits with descriptive messages.

  • (5 points): As a developer, I want to store my destinations, restaurants, mode of transportation, and entertainments in their own separate lists.

  • (5 points): As a user, I want a destination to be randomly selected for my day trip.

  • (5 points): As a user, I want a restaurant to be randomly selected for my day trip.

  • (5 points): As a user, I want a mode of transportation to be randomly selected for my day trip.

  • (5 points): As a user, I want a form of entertainment to be randomly selected for my day trip.

  • (15 points): As a user, I want to be able to randomly re-select a destination, restaurant, mode of transportation, and/or form of entertainment if I don’t like one or more of those things.

  • (10 points): As a user, I want to be able to confirm that my day trip is “complete” once I like all of the random selections.

  • (10 points): As a user, I want to display my completed trip in the console.

  • (5 points): As a developer, I want all of my functions to have a Single Responsibility. Remember, each function should do just one thing!

import random


destination_list = ['New York', 'Paris', 'Oslo', 'Dublin', 'Tokyo']
restaurant_list = ['Italian Restaurant', 'Sushi Restaurant',
                   'Burger Restaurant', 'Pizza Restaurant', 'Greek Restaurant']
transportation_list = ['train', 'car', 'motorcycle',
                       'helicopter', 'limo', 'monster truck']
entertainment_list = ['Broadway show', 'movie', 'miniature golf',
                      'opera music', 'live jazz', 'videogame and beer place']


def greeting():
    return print("Welcome to the Day Trip Generator! If you aren't sure what to do for your trip, you have come to the right place!")


def random_from_list_generator(list, element_from_list=''):
    index = random.randrange(0, len(list))
    new_element = list[index]
    if new_element != element_from_list:
        return new_element
    else:
        return random_from_list_generator(list, new_element)


# Destination
def get_user_input_destination(random_element_from_list, alt_message_bool=False):
    if alt_message_bool == False:
        user_input = input(
            f'We have selected {random_element_from_list} for your destination! Does this sound good? y/n: ')
    else:
        user_input = input(
            f'Oh sorry, you do not like this destination. No worries, we can try something else! How about {random_element_from_list}? Does this sound good? y/n: ')
    if user_input == 'n':
        random_destination = random_from_list_generator(
            destination_list, random_element_from_list)
        get_user_input_destination(random_destination, True)
    else:
        return random_element_from_list


# Transportation
def get_user_input_transportation(random_element_from_list, alt_message_bool=False):
    if alt_message_bool == False:
        user_input = input(
            f'We have selected {random_element_from_list} for your transportation! Does this sound good? y/n: ')
    else:
        user_input = input(
            f'Oh sorry, would you prefer another means of getting around? No worries, we can try something else! How about a {random_element_from_list}? Does this sound good? y/n: ')
    if user_input == 'n' or user_input == '':
        random_transportation = random_from_list_generator(
            transportation_list, random_element_from_list)
        get_user_input_transportation(random_transportation, True)
    else:
        return random_element_from_list

# Restaurant
def get_user_input_restaurant(random_element_from_list, alt_message_bool=False):
    if alt_message_bool == False:
        user_input = input(
            f'We have selected a {random_element_from_list} for your dining pleasure! Does this sound good? y/n: ')
    else:
        user_input = input(
            f'Oh sorry, you do not like this restaurant? No worries, we can try something else! How about a {random_element_from_list}? Does this sound good? y/n: ')
    if user_input == 'n' or user_input == '':
        random_restaurant = random_from_list_generator(
            restaurant_list, random_element_from_list)
        get_user_input_restaurant(random_restaurant, True)
    else:
        return random_element_from_list

# Entertainment
def get_user_input_entertainment(random_element_from_list, alt_message_bool=False):
    if alt_message_bool == False:
        user_input = input(
            f'We have selected a {random_element_from_list} for your entertainment during your stay! Does this sound good? y/n: ')
    else:
        user_input = input(
            f'Oh sorry, you do not like this type of entertainment? No worries, we can try something else! How about a {random_element_from_list}? Does this sound good? y/n: ')
    if user_input == 'n' or user_input == '':
        random_entertainment = random_from_list_generator(
            entertainment_list, random_element_from_list)
        get_user_input_entertainment(random_entertainment, True)
    else:
        return random_element_from_list


# Finalize Transaction
def finalize_transaction():
    new_line = '\n'
    print(
        f'Awesome! Glad that was decided! Lets move on!{new_line}Congrats! We have completed you trip. Now lets confirm everything.')
    print(
        f'The trip we generated for you is:{new_line}Destination: {destination_chosen}{new_line}Transportation: {transportation_chosen}')
    print(
        f'Restaurant: {restuarant_chosen}{new_line}Entertainment: {entertainment_chosen}{new_line}')
    would_like_to_finalize_trip = input(
        'Would you like to finalize this trip? Enter y/n: ')
    if would_like_to_finalize_trip == 'y':
        handle_final_message()
    else:
        handle_modify_booking()

def handle_final_message():
    print(
        f'Prepare for a wonderful trip we booked for you! You will be arriving to {destination_chosen} by {transportation_chosen} where you will spend the day checking out {entertainment_chosen}.')
    print(
        f'When you are hungry you will have directions to the {restuarant_chosen} we picked out for you.')
    print('Thank you for booking with us and enjoy your stay!')
    print('Arbitrary explanation mark !')
    print('This time two!!')


def handle_modify_booking():
   new_line = '\n'        
   print(f'Oh, so which would you like to modify? {new_line} a: destination {new_line} b: transportation {new_line} c: entertainment {new_line} d: restaurant {new_line}')
   user_input = input('Please provide answer here ( a b c OR d ):  ')
   if user_input == 'a':
      destination_chosen = get_user_input_destination(random_destination)
      finalize_transaction()
   elif user_input == 'b':
      transportation_chosen = get_user_input_transportation(random_transportation)
      finalize_transaction()
   elif user_input == 'c':
      entertainment_chosen = get_user_input_entertainment(random_entertainment)
      finalize_transaction()
   elif user_input == 'd':
      restuarant_chosen = get_user_input_restaurant(random_restaurant)
      finalize_transaction()

greeting()

random_destination = random_from_list_generator(destination_list)

destination_chosen = get_user_input_destination(random_destination)

random_transportation = random_from_list_generator(transportation_list)

transportation_chosen = get_user_input_transportation(random_transportation)

random_restaurant = random_from_list_generator(restaurant_list)

restuarant_chosen = get_user_input_restaurant(random_restaurant)

random_entertainment = random_from_list_generator(entertainment_list)

entertainment_chosen = get_user_input_entertainment(random_entertainment)

finalize_transaction()