Git Product home page Git Product logo

passengers_and_vehicles_2303's Introduction

Passengers and Vehicles Instructions

Iteration 1

Setup

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

Use TDD to create a Passenger class that responds to the following interaction pattern. For the adult? method, a Passenger is considered an adult if they are age 18 or older.

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

pry(main)> charlie = Passenger.new({"name" => "Charlie", "age" => 18})    
# => #<Passenger:0x00007fc1ad88b3c0...>

pry(main)> taylor = Passenger.new({"name" => "Taylor", "age" => 12})    
# => #<Passenger:0x00007fe0da2cf1b0...>

pry(main)> charlie.name
# => "Charlie"

pry(main)> charlie.age
# => 18

pry(main)> charlie.adult?
# => true

pry(main)> taylor.adult?
# => false

pry(main)> charlie.driver?
# => false

pry(main)> charlie.drive

pry(main)> charlie.driver?
# => true

Iteration 2

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

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

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

pry(main)> vehicle = Vehicle.new("2001", "Honda", "Civic")    
# => #<Vehicle:0x00007fe0da9c63d8...>

pry(main)> vehicle.year
# => "2001"

pry(main)> vehicle.make
# => "Honda"

pry(main)> vehicle.model
# => "Civic"

pry(main)> vehicle.speeding?
# => false

pry(main)> vehicle.speed

pry(main)> vehicle.speeding?
# => true

pry(main)> vehicle.passengers
# => []

pry(main)> charlie = Passenger.new({"name" => "Charlie", "age" => 18})    
# => #<Passenger:0x00007fe0da1ec450...>

pry(main)> jude = Passenger.new({"name" => "Jude", "age" => 20})    
# => #<Passenger:0x00007fe0da2730e0...>

pry(main)> taylor = Passenger.new({"name" => "Taylor", "age" => 12})    
# => #<Passenger:0x00007fe0da2cf1b0...>

pry(main)> vehicle.add_passenger(charlie)    

pry(main)> vehicle.add_passenger(jude)    

pry(main)> vehicle.add_passenger(taylor)    

pry(main)> vehicle.passengers
# => [#<Passenger:0x00007fe0da1ec450...>, #<Passenger:0x00007fe0da2730e0...>, #<Passenger:0x00007fe0da2cf1b0...>]

pry(main)> vehicle.num_adults
# => 2

Iteration 3

You have been contracted by the National Park Service to create a program that can track revenue for its parks. Specifically, they would like you to implement the following features:

  1. Create a Park class. Each park has a unique name and admission price, as well as a way to read that data.
  2. Each park has vehicles that entered the park, as well as a way to read that data.
  3. Each park can list all passengers that were in the vehicles that entered the park.
  4. Each park can calculate revenue generated. Revenue is generated by charging the admission price per adult that entered the park.

Build upon your existing code from the first two iterations to implement this functionality.

Method Name Return Value (type)
name String
admission_price integer
vehicles Array of Vehicle objects
add_vehicle(vehicle) vehicles (Array of Vehicle objects)
passengers Array of Passenger objects
revenue Integer

Iteration 4

The National Park Service has given you additional functionality it would like you to implement. They would like to be able to track patrons of their parks.

  1. Generate a list of all all_attendees names, sorted alphabetically.
  2. Generate a list of all minors names, sorted alphabetically.
  3. Generate a list of all adults names, sorted alphabetically.

Build upon your existing code from the first three iterations to implement this functionality.

Method Name Return Value (type)
all_attendees Array of Passenger names as strings
minors Array of Passengers who are minors; names as strings
adults Array of Passengers who are adults; names as strings

passengers_and_vehicles_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.