Last active
January 9, 2017 10:35
-
-
Save monabat79/562edf5086522e63054b08aeb851c55e to your computer and use it in GitHub Desktop.
messing around with ruby
This file contains hidden or 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 "date" | |
| class DatBoi | |
| attr_accessor :name | |
| attr_accessor :life | |
| attr_accessor :bornIn | |
| attr_accessor :currentDate | |
| attr_accessor :alive | |
| def initialize(name = "Dat Boi", life = 365*4, bornIn = Date.parse("2016-04-03")) | |
| @name = name | |
| @life = life | |
| @bornIn = bornIn | |
| @currentDate = @bornIn | |
| @alive = true | |
| puts "The current date is #{@currentDate}." | |
| end | |
| def come() | |
| if @alive | |
| puts "here come #{@name}!\no shit waddup!" | |
| live() | |
| else | |
| puts "#{@name} is a dead meme." | |
| end | |
| end | |
| def live(days = 1) | |
| if @alive | |
| @life -= days | |
| @currentDate += days | |
| if days == 1 | |
| puts "#{@name} lives for 1 day..." | |
| else | |
| puts "#{@name} lives for #{days} days..." | |
| end | |
| if @life > 0 | |
| puts "#{@name} is still famous!" | |
| else | |
| @alive = false | |
| puts "#{@name} is a dead meme." | |
| end | |
| puts "The current date is #{@currentDate}." | |
| end | |
| end | |
| end | |
| if __FILE__ == $0 | |
| db = DatBoi.new() | |
| db.come() | |
| db.live(20) | |
| db.come() | |
| db.live(40*23) | |
| db.come() | |
| db.live(365*2) | |
| db.come() | |
| end |
This file contains hidden or 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 "DatBoi" | |
| puts "A new meme is born, and it's name is..." | |
| dg = DatBoi.new("Dat Girl", 365*3, Date.parse("2017-01-18")) | |
| puts "...#{dg.name}." | |
| dg.come() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment