Coder Social home page Coder Social logo

kwk-l1-oo-cash-register-sgharms-test-webdev-fund's Introduction

Cha Ching!

Amazon needs a new payment app. You're a Director of Engineering at Amazon, and the CTO just came to you and asked you to rewrite their payment app in time for their Christmas rush. You now need to build an app that can support 426 purchases per second.

Instructions

Follow along with the specs in spec/amazon_transaction_spec.rb. Remember to run your specs in the terminal by entering learn from the main directory of this lab.

Write your code in the amazon_transaction.rb file.

Take it one step at a time, peeps!

After You Pass All The Tests...

Build out four more methods of your choice for your cash register. Think about what functionality would be useful. Maybe you want to build out an amazon_prime method that will give a customer free shipping if they have Amazon prime. Or maybe you want the register to print a receipt by putsing the details of the transaction to go in the box with the user's purchase. How would you build a print_receipt method? Maybe there is a gift_box method that prints out a guest receipt without the cost of the item, and gives the user an option to add a note.

Bonus

Go to amazon_transaction_spec.rb and uncomment the extra tests. Each bonus increases in difficulty and cover new concepts we haven't taught you in class yet. If you've made it to the bonuses then you already know how to build the business logic or back-end of an app. Hooray! These provide just a little extra push if you're looking for even more of a challenge.

Bonus 1: Build a method called cancel_order that will remove the last transaction from the total. You'll need to make an additional attribute accessor and keep track of that last transaction amount somehow. Hint: in what method of the class are you working with an individual item?

Bonus 2: Amazon keeps a history of it's user's transactions so they can access them later in case the customer needs a refund or wants to see past purchases. For this challenge, you'll need to add a randomly generated numeric code as an attribute to the transaction. Then, you'll need to use a class variable to store each transaction's code so Amazon can easily look up each transaction later.

Bonus 3: Want to make your cash register even more realistic? We can use Ruby to write text into different types of files. So instead of printing to the screen you could write a print_receipt method that can actually put the transaction details in a receipt.txt file, which your customers can print out or save. To complete this bonus you'll need to do a bit of research on how to do this (hint: look up File; it's a built-in Ruby class!)

And that's all folks! You've successfully built an object-oriented payment app!

Resources

KWK-L1 Cha Ching!

kwk-l1-oo-cash-register-sgharms-test-webdev-fund's People

Contributors

danielseehausen avatar aviflombaum avatar dfenjves avatar

Watchers

 avatar Rishikesh Tirumala avatar James Cloos avatar  avatar Victoria Thevenot avatar  avatar Joe Cardarelli avatar Katie Burke avatar Sara Tibbetts avatar The Learn Team avatar Sophie DeBenedetto avatar  avatar Antoin avatar Alex Griffith avatar  avatar Amanda D'Avria avatar  avatar Nicole Kroese  avatar Lisa Jiang 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.