hschuster9 / ruby-cli-lab

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Ruby CLI Lab

Today is your chance to practice Ruby. You'll have the option to choose one of three prompts (ranked by difficulty):

  1. Flash Cards
  2. Personal Finance
  3. Battleship

Getting Started

Think about how you want to structure your application. Will you have a Menu class?

Here's an example:

class Menu
  def self.display
    while 1
      puts "Choose one of the following:"
      puts "1 - Option 1"
      puts "2 - Option 2"
      puts "3 - Option 3"
      input = gets.chomp
      if ["1","2","3"].include? input
        self.select input
        break
      else
        puts "Invalid option."
      end
    end
  end
  def self.select number
    puts "You selected #{number}"
  end
end

Menu.display

What other classes will you have? A flashcard?

class Flashcard
  attr_accessor :front, :back
  def initialize front, back
    @front = front
    @back = back
  end
end

Flashcard.new "Buenos Dias", "Good morning"

About


Languages

Language:Ruby 100.0%