backend-1-week-4-micronix:GitHub Classroom创建的backend-1-week-4-mi

  • p3_856840
    了解作者
  • 1.5KB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • VIP专享
    资源类型
  • 0
    下载次数
  • 2022-06-13 20:12
    上传日期
backend1 -week-4 创建一个名为backend-1-lesson-4的git分支,并将以下ruby程序放入其中。 (1)编写一个方法,该方法在数组中返回可以被2或3或5整除的1到100之间的所有数字。然后在程序中调用该方法并打印出它返回的内容。 调用程序divisible.rb。 (2)编写一个程序hangman.rb,其中包含一个名为hangman的函数。 该函数的参数是一个单词和一个字母数组。 它返回一个字符串,显示已被猜测的字母。 从您的程序中调用该函数,以便您知道它可以工作。 示例:hangman(“ bob”,[“ b”])应该计算为“ b_b”示例:hangman(“ alphabet”,[“ a”,“ h”])应该返回“ a__ha___” (3)编写一个程序,该程序从用户那里收集5个键和5个值,并将它们存储在哈希中。 编写一个函数,该函数接受哈希作为
backend-1-week-4-micronix-master.zip
  • backend-1-week-4-micronix-master
  • .github
  • .keep
    0B
  • README.md
    1.9KB
内容介绍
# backend1-week-4 Create a git branch called backend-1-lesson-4 and put the following ruby programs in it. (1) Write a method that returns in an array all the numbers between 1 and 100 that are divisible by 2 or 3 or 5. Then call the method in your program and print out what it returns. Call the program divisible.rb. (2) Write a program hangman.rb that contains a function called hangman. The function's parameters are a word and an array of letters. It returns a string showing the letters that have been guessed. Call the function from within your program so that you know that it works. Example: hangman("bob",["b"]) should evaluate to "b_b" Example: hangman("alphabet",["a","h"]) should return "a__ha___" (3) Write a program that collects 5 keys and 5 values from the user, and stores them in a hash. Write a function that accepts the hash as optional parameters and prints out an array of keys and an array of values. Call the function within your program so you know it works. (Question: Can you find online information on Ruby hash methods that will help with this function?) Call this program hash_to_array.rb. (4) Create a program sums.rb with two classes. (a) a class called Sum1 with an initialize method that takes two parameters and sets the instance variable total to the sum of the two. Include a line at the top of the class: attr_accessor :total (b) a class called Sum2 with an initialize method that takes two parameters a and b and sets the instance variable a to the parameter a and the instance variable b to the parameter b. Create a method new_total inside Sum2 that returns the sum of the instance variables a and b. (c) In the mainline program, create instances of Sum1 and Sum2, passing 5 and 6 as parameters on the new statement. Print out the total for Sum1. Print out the new_total for Sum2. Then push your changes to github and issue a pull request.
评论
    相关推荐
    • libsixel-ruby
      libsixel gem为libsixel( )提供了Ruby语言绑定。 要求 libsixel(> = 1.5.0) 安装 gem 'libsixel-ruby' 然后执行: $ bundle 或将其自己安装为: $ gem install libsixel-ruby 用法 require 'libsixel' ...
    • git-exercises:练习git命令和理解git repos的练习。 Ruby,Rspec
      git-exercises:练习git命令和理解git repos的练习。 Ruby,Rspec
    • rgit:GitRuby实现
      RGit是Git的简单Ruby实现,用于了解Git内部如何工作。 目的不是要成为一个健壮的或可用于生产的工具。 相反,它作为了解git如何工作的学习助手而存在。 因此,许多实施决策都倾向于采用幼稚且过于简化的方法。 阅读...
    • Ruby-gitautobisectFindthecommitthatbrokemaster
      git-auto-bisect - Find the commit that broke master
    • Ruby-GLI类似Git接口的命令行解析器
      GLI - 类似Git接口的命令行解析器
    • Ruby-GitCop强制执行一致的Git提交
      强制Git rebase工作流与一致的Git提交一个干净,易于阅读/调试项目历史
    • gitit:Ruby命令行git wrapper
      吉蒂特 待办事项:撰写宝石说明 ...创建功能分支( git checkout -b my-new-feature ) 提交更改( git commit -am 'Add some feature' ) 推送到分支( git push origin my-new-feature ) 创建新的拉取请求
    • git-revision:Ruby gem获取有关git源代码的信息
      Git Revision是一个简单的(45 SLoC)Ruby gem,提供有关git源代码的基本信息。 您可以在应用程序中使用它,显示已部署的版本。 安装 添加到Gemfile: gem 'git-revision' 并运行: bundle install 用法 Git::...
    • finicity-ruby
      Finicity::Ruby 待办事项:写一个宝石描述 安装 将此行添加到应用程序的 Gemfile 中: gem 'finicity-ruby' 然后执行: $ bundle 或者自己安装: $ gem install finicity-ruby 用法 TODO:在这里写使用说明 ...
    • Ruby-不gitcommit当你drunk时
      git commit当你drunk时