-
-
Save go-east/ecca3548e9c6ec5481fafe6c19ad605c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require_relative "wagon_sort" | |
def prompt | |
gets.chomp | |
end | |
def add_students(student, array) | |
array.push(student) | |
end | |
def menu | |
array = [] | |
input = nil | |
until input == "" | |
puts "type a student name :> " | |
input = prompt | |
puts add_students(input, array) | |
end | |
array = wagon_sort(array) | |
puts "Congratulations! Your Wagon has #{array.length} students:" | |
print "- " | |
print "#{array[0]}" | |
array[1..-2].each do |x| | |
print "#{x}, " | |
end | |
print "#{array[-2]} and #{array[-1]}" | |
end | |
menu |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment