This project is an app that uses conditional and looping structures to modify program flow and responds to user input based on the entered message. The app has a controller that includes if/else statements to modify the program flow and provide appropriate responses to user messages. The app is designed to respond differently based on the type of message entered, such as a statement or a question, and provides specific responses based on the input.
- conditional and looping structures
- execution flow and control structures that modify the program flow (ie if/unless...else...end, while/until...end).
The idea is that when you enter a message and click the "talk" button, Coach Hell responds with a message of his own, based on your message.
When you enter a question such as "Do I have to work?", Coach Hell responds...
When you enter a statement such as "I'm tired", Coach Hell responds...
However, when you enter "I'm going to work", Coach Hell responds...
Here is the code for the controller, which shows the if/else statements that modify the program flow:
class CommunicationsController < ApplicationController
def ask; end
def answer
@talk = params[:talk]
if @talk == "I'm going to work"
@answer = 'Great!'
elsif @talk.end_with?('?')
@answer = 'SILLY QUESTION! GET DRESSED AND GO TO WORK!'
else
@answer = "I DON'T CARE, GET DRESSED AND GO TO WORK!"
end
end
end
git clone [email protected]:guavalines/rails-stupid-coaching.git
cd rails-stupid-coaching
rails db:create db:migrate db:seed:replant
bundle install
yarn install
rails server
Open your browser and visit localhost:3000