Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bryan A username generator #11

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 39 additions & 6 deletions username.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,47 @@
# Make sure to run the tests in your /spec folder
# Run `rspec /spec/username_spec.rb` to get started.

def format_name(first, last)
nil
def format_name(first_name, last_name)
correct_name = first_name.split.join
if (first_name != "" && last_name != "")
user_name = correct_name[0] + last_name.split.join('')
new_user_name = user_name.downcase
end
end

def format_year
nil
def format_year(year)
user_year = year.to_s
if user_year.length == 4
user_year[2,3]
else nil
end
end

def build_username
nil
def build_username(first_name, last_name, year)
user_build = first_name[0] + last_name
name = user_build.downcase
year_build = year.to_s
user_year = year_build[2,3]
built_user = name + user_year
end
# write an if statement to return the user type
# use math.floor to round down to the lowest number
# reminder to read all errors you are receiving
# write elsif statement to try and get this to work
# try not to overthink it
# num = ["user", "seller", "manager", "admin"]
def check_privilege(num = 0)

if num.floor == 0
"user"
elsif num.floor == 1
"seller"
elsif num.floor == 2
"manager"
else
"admin"
end
end

def generate_username (first_name, last_name, birth_year, privilege_level)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job Bryan - this code you've written looks good. I encourage you to try and finish this lab when you can because it's great practice!

end
17 changes: 11 additions & 6 deletions warmup.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
# Run `rspec spec/the_warmup_spec.rb` to get started.

def say_hello
"hi"
"hello"
end

def scream(message)
message
message = "boo"
message.upcase + "!"
end

def first_char
"z"
def first_char(input)
input[0].downcase
end

def polly_wanna
"crackercrackercracker"
def polly_wanna(word)
word * 4
end

def after_you
"no, after you"
end