diff --git a/README.md b/README.md index e1227ca..3616302 100644 --- a/README.md +++ b/README.md @@ -34,10 +34,10 @@ ### 🌸🌷 Key Features -- **[Implementation of functions using ```def...end``` syntax]** -- **[Display output using ```puts ...```]** -- **[Create classes using ```class...end``` syntax]** -- **[Retrieve data from the existing file and save to their relevant arrays]** +- **[Add new book]** +- **[Add new games]** +- **[Add new music albums]** +- **[List all items added]**
@@ -66,7 +66,7 @@ Clone this repository to your desired folder: - 🌷LinkedIn: [LinkedIn](https://www.linkedin.com/in/ivonnebenites/) -👤 *Gilbert Dushimimana Happi* +👤 *Gilbert Happi* - Github: [Gilbert Happi Dushimimana](https://github.com/gilberthappi) - X: [Gilbert Happi Dushimimana](https://twitter.com/DushimimanaGil3) @@ -77,11 +77,11 @@ Clone this repository to your desired folder: ## 🔭🌷 Future Features -- [ ] **[User Authentication]** -- [ ] **[Search Functionality]** -- [ ] **[Data Export/Import ]** -- [ ] **[Items Review]** - +- [ ] **[Add movies]** +- [ ] **[List movies]** +- [ ] **[Add new book]** +- [ ] **[Add new music albums]** +- [ ] **[List all items added]** @@ -102,7 +102,7 @@ If you find this project helpful, consider giving a star ⭐️ to show your sup ## 🙏 Acknowledgments -I would like to thank Microverse for this great opportunity. +We would like to thank Microverse for this great opportunity. diff --git a/classes/author.rb b/classes/author.rb new file mode 100644 index 0000000..eb5910d --- /dev/null +++ b/classes/author.rb @@ -0,0 +1,15 @@ +class Author + attr_reader :id + attr_accessor :first_name, :last_name, :items + + def initialize(first_name, last_name) + @id = Random.rand(1..1000) + @first_name = first_name + @last_name = last_name + @items = [] + end + + def add_item(item) + @items << item + end +end diff --git a/classes/game.rb b/classes/game.rb new file mode 100644 index 0000000..d137da1 --- /dev/null +++ b/classes/game.rb @@ -0,0 +1,16 @@ +require_relative 'item' +require 'date' + +class Game < Item + attr_accessor :publish_date, :multiplayer, :last_played_at + + def initialize(publish_date, multiplayer, last_played_at) + super(publish_date) + @multiplayer = multiplayer + @last_played_at = last_played_at + end + + def can_be_archived? + super && (Date.today - Date.parse(@last_played_at) > 2) + end +end diff --git a/classes/item.rb b/classes/item.rb index b4a3b34..bc11d94 100644 --- a/classes/item.rb +++ b/classes/item.rb @@ -1,9 +1,10 @@ +require 'date' class Item attr_reader :id, :publish_date - def initialize(_publish_date, archived: true) + def initialize(publish_date, archived: true) @id = Random.rand(1..1000) - @publish_date = date + @publish_date = Date.parse(publish_date) @archived = archived end @@ -33,9 +34,8 @@ def move_to_archive @archived = true end - private - def can_be_archived? - publish_date < 10.years.ago + ten_years_ago = Date.today - (10 * 365) + publish_date < ten_years_ago end end