GithubHelp home page GithubHelp logo

oystercard's Introduction

oystercard

User stories & feature tests output with the use of irb:

In order to use public transport
As a customer
I want money on my card

:pending output
In order to keep using public transport
As a customer
I want to add money to my card

:pending output
In order to protect my money from theft or loss
As a customer
I want a maximum limit (of £90) on my card

:pending output
In order to pay for my journey
As a customer
I need my fare deducted from my card

:pending output
In order to get through the barriers.
As a customer
I need to touch in and out.

2.7.0 :001 > require  './lib/oystercard.rb'
 => true 
2.7.0 :002 > oyster = Oystercard.new
2.7.0 :003 > oyster.in_journey
 => false 
2.7.0 :004 > oyster.touch_in
 => true 
2.7.0 :005 > oyster.in_journey
 => true 
2.7.0 :006 > oyster.touch_out
 => false 
2.7.0 :007 > oyster.in_journey
 => false
In order to pay for my journey
As a customer
I need to have the minimum amount (£1) for a single journey.

2.7.0 :003 > oyster.balance
 => 0
2.7.0 :004 > oyster.touch_in
        5: from /Users/.../.rvm/rubies/ruby-2.7.0/bin/irb:23:in `<main>'
        3: from /Users/.../.rvm/rubies/ruby-2.7.0/lib/ruby/gems/2.7.0/gems/irb-1.2.1/exe/irb:11:in `<top (required)>'
        2: from (irb):4
        1: from /Users/.../Documents/.../.../oystercard/lib/oystercard.rb:22:in `touch_in'
RuntimeError (Cannot enter if balance is below £1)
2.7.0 :005 > oyster.top_up(1)
 => 1 
2.7.0 :006 > oyster.balance
 => 1 
2.7.0 :007 > oyster.touch_in
 => true 
2.7.0 :008 > oyster.in_journey
 => true 
2.7.0 :009 > oyster.touch_out
 => false 
2.7.0 :010 > oyster.in_journey
 => false 
In order to pay for my journey
As a customer
When my journey is complete, I need the correct amount deducted from my card

 2.7.0 :003 > oyster.top_up(10)
 => 10 
2.7.0 :004 > oyster.touch_in
 => true 
2.7.0 :005 > oyster.touch_out
 => false 
2.7.0 :006 > oyster.balance
 => 9 
In order to pay for my journey
As a customer
I need to know where I've travelled from

2.7.0 :003 > oyster
 => #<Oystercard:0x00007ffb9e1412b0 @balance=0, @entry_station=nil> 
2.7.0 :004 > oyster.top_up(5)
 => 5 
2.7.0 :005 > oyster.touch_in('Paddington')
 => "Paddington" 
2.7.0 :006 > oyster
 => #<Oystercard:0x00007ffb9e1412b0 @balance=5, @entry_station="Paddington"> 
2.7.0 :007 > oyster.in_journey?
 => true 
2.7.0 :008 > oyster.touch_out
 => nil 
2.7.0 :009 > oyster
 => #<Oystercard:0x00007ffb9e1412b0 @balance=4, @entry_station=nil> 
2.7.0 :010 > oyster.in_journey?
 => false
In order to know where I have been
As a customer
I want to see all my previous trips

 2.7.0 :004 > oyster.top_up(5)
 => 5 
2.7.0 :005 > oyster.touch_in('Paddington')
 => "Paddington" 
2.7.0 :006 > oyster.touch_out('Marylebone')
 => nil 
2.7.0 :007 > oyster.journeys_history
 => [{:entry_station=>"Paddington", :exit_station=>"Marylebone"}] 
2.7.0 :008 > oyster.touch_in('Pimlico')
 => "Pimlico" 
2.7.0 :009 > oyster.journeys_history
 => [{:entry_station=>"Paddington", :exit_station=>"Marylebone"}] 
2.7.0 :010 > oyster.touch_out('Vauxhaull')
 => nil 
2.7.0 :011 > oyster.journeys_history
 => [{:entry_station=>"Paddington", :exit_station=>"Marylebone"}, {:entry_station=>"Pimlico", :exit_station=>"Vauxhaull"}]  
 oyster.show_journeys
 => [{:entry_station=>"Paddington", :exit_station=>"Marylebone"}] 

 short version:
 2.7.0 :003 > oyster.top_up(5)
 => 5 
2.7.0 :004 > oyster.touch_in('Paddington')
 => "Paddington" 
 2.7.0 :005 > oyster.touch_out('Marylebone')
 => nil 
 2.7.0 :007 > oyster.show_journeys
 => [{:entry_station=>"Paddington", :exit_station=>"Marylebone"}]
 In order to know how far I have travelled
As a customer
I want to know what zone a station is in

:pending output

oystercard's People

Contributors

iliasmariosg avatar

Watchers

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