Git Product home page Git Product logo

sports_ball_2303's Introduction

Sports Ball

Instructions

  • Fork this Repository
  • Clone YOUR fork
  • Complete the activity below
  • Push your solution to a fork
  • Submit a pull request from your repository to the turingschool-examples repository
  • Make sure to put your name in your PR!

Iteration 1

Start with the existing tests, and then use TDD to create a Player class that responds to the following interaction pattern. You are expected to write your own tests for the set_nickname! and nickname methods.

(Where you see something like #<Playerr:0x00007fccd30375f8...>, this is shorthand for a full player object with that object identifier - we have replaced any attributes with ... for readability.)

Notes: Contract length is in months, and the total cost is the contract length multiplied by the monthly cost.

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

pry(main)> player = Player.new("Michael Palledorous" , 1000000, 36)
#=> #<Player:0x00007fa53b9ca0a8...>

pry(main)> player.first_name
#=> "Michael"

pry(main)> player.last_name
#=> "Palledorous"

pry(main)> player.monthly_cost
#=> 1000000

pry(main)> player.contract_length
#=> 36

pry(main)> player.total_cost
#=> 36000000

pry(main)> player.nickname
#=> nil

pry(main)> player.set_nickname!("Squints")

pry(main)> player.nickname
#=> "Squints

Iteration 2

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

(Where you see something like #<Team:0x00007fccd30375f8...>, this is shorthand for a full team object with that object identifier - we have replaced any attributes with ... for readability.)

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

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

pry(main)> team = Team.new("Dodgers", "Los Angeles")
#=> #<Team:0x00007fccd30375f8...>

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

pry(main)> team.player_count
#=> 0

pry(main)> player_1 = Player.new("Michael Palledorous" , 1000000, 36)
#=> #<Player:0x00007fa53b9ca0a8...>

pry(main)> player_2 = Player.new("Kenny DeNunez", 500000, 24)
#=> #<Player:0x00007fccd2985f48...>

pry(main)> team.add_player(player_1)

pry(main)> team.add_player(player_2)

pry(main)> team.roster
#=> [#<Player:0x00007fa53b9ca0a8...>, #<Player:0x00007fccd2985f48...>]

pry(main)> team.player_count
#=> 2

Iteration 3

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

  • Player is considered a long term player if their contract length is greater than two years.
  • Player is considered a short term player if their contract length is two years or less.
  • total_value is the total cost of all of the players.
pry(main)> require './lib/player'
#=> true

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

pry(main)> team = Team.new("Dodgers", "Los Angeles")
#=> #<Team:0x00007fccd30375f8...>

pry(main)> player_1 = Player.new("Michael Palledorous" , 1000000, 36)
#=> #<Player:0x00007fa53b9ca0a8...>

pry(main)> player_2 = Player.new("Kenny DeNunez", 500000, 24)
#=> #<Player:0x00007fccd2985f48...>

pry(main)> player_3 = Player.new("Alan McClennan", 750000, 48)
#=> #<Player:0x00007fccd383c2d0...>

pry(main)> player_4 = Player.new("Hamilton Porter", 100000, 12)
#=> #<Player:0x00007fccd297dc30...>

pry(main)> team.add_player(player_1)

pry(main)> team.add_player(player_2)

pry(main)> team.add_player(player_3)

pry(main)> team.add_player(player_4)

pry(main)> team.long_term_players
#=> [#<Player:0x00007fa53b9ca0a8...>, #<Player:0x00007fccd383c2d0...>]

pry(main)> team.short_term_players
#=> [#<Player:0x00007fccd297dc30...>, #<Player:0x00007fccd2985f48...>]

pry(main)> team.total_value
#=> 85200000

pry(main)> team.details
#=> {"total_value" => 85200000, "player_count" => 4}

Iteration 4

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

  • Players sorted by last name should be in descending alphabetical order.
pry(main)> require './lib/player'
#=> true

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

pry(main)> team = Team.new("Dodgers", "Los Angeles")
#=> #<Team:0x00007fccd30375f8...>

pry(main)> player_1 = Player.new("Michael Palledorous" , 1000000, 36)
#=> #<Player:0x00007fa53b9ca0a8...>

pry(main)> player_2 = Player.new("Kenny DeNunez", 500000, 24)
#=> #<Player:0x00007fccd2985f48...>

pry(main)> player_3 = Player.new("Alan McClennan", 750000, 48)
#=> #<Player:0x00007fccd383c2d0...>

pry(main)> player_4 = Player.new("Hamilton Porter", 100000, 12)
#=> #<Player:0x00007fccd297dc30...>

pry(main)> team.add_player(player_1)

pry(main)> team.add_player(player_2)

pry(main)> team.add_player(player_3)

pry(main)> team.add_player(player_4)

pry(main)> team.average_cost_of_player
#=> "$21,300,000"

pry(main)> team.players_by_last_name
#=> "DeNunez, McClennan, Palledorous, Porter"

sports_ball_2303's People

Contributors

garrettgregor avatar dcoleman21 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.