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

Create-Game-class-&&-Create-Author-class-add-methods-Task1andTask2 #26

Merged
merged 5 commits into from
Nov 29, 2023
Merged
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
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@
</details>

### 🌸🌷 Key Features <a name="key-features"></a>
- **[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]**

<p align="right">(<a href="#readme-top">back to top</a>)</p>

Expand Down Expand Up @@ -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)
Expand All @@ -77,11 +77,11 @@ Clone this repository to your desired folder:

## 🔭🌷 Future Features <a name="future-features"></a>

- [ ] **[User Authentication]**
- [ ] **[Search Functionality]**
- [ ] **[Data Export/Import ]**
- [ ] **[Items Review]**
- [ ] **[Add movies]**
- [ ] **[List movies]**
- [ ] **[Add new book]**
- [ ] **[Add new music albums]**
- [ ] **[List all items added]**

<p align="right">(<a href="#readme-top">back to top</a>)</p>

Expand All @@ -102,7 +102,7 @@ If you find this project helpful, consider giving a star ⭐️ to show your sup

## 🙏 Acknowledgments <a name="acknowledgements"></a>

I would like to thank Microverse for this great opportunity.
We would like to thank Microverse for this great opportunity.

<p align="right">(<a href="#readme-top">back to top</a>)</p>

Expand Down
15 changes: 15 additions & 0 deletions classes/author.rb
Original file line number Diff line number Diff line change
@@ -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
16 changes: 16 additions & 0 deletions classes/game.rb
Original file line number Diff line number Diff line change
@@ -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
10 changes: 5 additions & 5 deletions classes/item.rb
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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
Loading