Giter Club home page Giter Club logo

world_cup's Introduction

World Cup

Instructions

  • Fork this Repository
  • Clone your forked repo to your computer.
  • Complete the activity below.
  • Push your solution to your forked repo
  • Submit a pull request from your repository to this repository
    • Put your name in your PR!

Iteration 1

Use TDD to create a Player class that responds to the following interaction pattern:

pry(main)> require './lib/player'
# => true

pry(main)> player = Player.new({name: "Luka Modric", position: "midfielder"})    
# => #<Player:0x00007fd8273d21e0...>

pry(main)> player.name
# => "Luka Modric"

pry(main)> player.position
# => "midfielder"

Iteration 2

Use TDD to create a Team class that responds to the following interaction pattern:

pry(main)> require './lib/team'
# => true

pry(main)> require './lib/player'
# => true

pry(main)> team = Team.new("France")    
# => #<Team:0x00007fe0d0335d48...>

pry(main)> team.country
# => "France"

pry(main)> team.eliminated?
# => false

pry(main)> team.eliminated = true

pry(main)> team.eliminated?
# => true

pry(main)> team.players
# => []

pry(main)> mbappe = Player.new({name: "Kylian Mbappe", position: "forward"})
# => #<Player:0x00007fe0d02bd280...>

pry(main)> pogba = Player.new({name: "Paul Pogba", position: "midfielder"})    
# => #<Player:0x00007fe0d0851138...>

pry(main)> team.add_player(mbappe)

pry(main)> team.add_player(pogba)    

pry(main)> team.players
# => [#<Player:0x00007fe0d02bd280...>, #<Player:0x00007fe0d0851138...>]

pry(main)> team.players_by_position("midfielder")
# => [#<Player:0x00007fe0d0851138...>]

pry(main)> team.players_by_position("defender")
# => []

Iteration 3

Use TDD to create a WorldCup class that responds to the following interaction pattern. For the active_players_by_position method, an active player is a player that is on a team that is not eliminated.

pry(main)> require './lib/world_cup'
# => true

pry(main)> require './lib/team'
# => true

pry(main)> require './lib/player'
# => true

pry(main)> france = Team.new("France")
# => #<Team:0x00007f936a313698...>

pry(main)> mbappe = Player.new({name: "Kylian Mbappe", position: "forward"})    
# => #<Player:0x00007f936a9168b0...>

pry(main)> pogba = Player.new({name: "Paul Pogba", position: "midfielder"})    
# => #<Player:0x00007f936c035eb0...>

pry(main)> france.add_player(mbappe)    

pry(main)> france.add_player(pogba)    

pry(main)> croatia = Team.new("Croatia")    
# => #<Team:0x00007f936a3afea8...>

pry(main)> modric = Player.new({name: "Luka Modric", position: "midfielder"})    
# => #<Player:0x00007f936a3595f8...>

pry(main)> vida = Player.new({name: "Domagoj Vida", position: "defender"})    
# => #<Player:0x00007f936a318f08...>

pry(main)> croatia.add_player(modric)    

pry(main)> croatia.add_player(vida)    

pry(main)> world_cup = WorldCup.new(2018, [france, croatia])    
# => #<WorldCup:0x00007f936a010d10...>

pry(main)> world_cup.year
# => 2018

pry(main)> world_cup.teams
# => [#<Team:0x00007f936a313698...>, #<Team:0x00007f936a3afea8...>]

pry(main)> world_cup.active_players_by_position("midfielder")
# => [#<Player:0x00007f936c035eb0...>, #<Player:0x00007f936a3595f8...>]

pry(main)> croatia.eliminated = true    

pry(main)> world_cup.active_players_by_position("midfielder")
# => [#<Player:0x00007f936c035eb0...>]

Iteration 4

Use TDD to update your WorldCup class so that it responds to the following interaction pattern:

pry(main)> require './lib/world_cup'
# => true

pry(main)> require './lib/team'
# => true

pry(main)> require './lib/player'
# => true

pry(main)> france = Team.new("France")
# => #<Team:0x00007f936a313698...>

pry(main)> mbappe = Player.new({name: "Kylian Mbappe", position: "forward"})    
# => #<Player:0x00007f936a9168b0...>

pry(main)> pogba = Player.new({name: "Paul Pogba", position: "midfielder"})    
# => #<Player:0x00007f936c035eb0...>

pry(main)> france.add_player(mbappe)    

pry(main)> france.add_player(pogba)    

pry(main)> croatia = Team.new("Croatia")    
# => #<Team:0x00007f936a3afea8...>

pry(main)> modric = Player.new({name: "Luka Modric", position: "midfielder"})    
# => #<Player:0x00007f936a3595f8...>

pry(main)> vida = Player.new({name: "Domagoj Vida", position: "defender"})    
# => #<Player:0x00007f936a318f08...>

pry(main)> croatia.add_player(modric)    

pry(main)> croatia.add_player(vida)    

pry(main)> world_cup = WorldCup.new(2018, [france, croatia])    
# => #<WorldCup:0x00007f936a010d10...>

world_cup.all_players_by_position
# =>
#   {
#     "forward" => [#<Player:0x00007ffb3a8a8fd0...>],
#     "midfielder" => [#<Player:0x00007ffb39a2dd48...>, #<Player:0x00007ffb3a054730...>],
#     "defender" => [#<Player:0x00007ffb3a8dbb38...>]
#   }

world_cup's People

Contributors

brianzanti avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.