Giter VIP home page Giter VIP logo

android_unittest_calculator's Introduction

Android Test Driven Design Calculator

For this app, you'll bulid a simple, basic calculator. The difference, is that you'll be using Test Driven design to do it.

You will also not be building a UI for this as we will be using TDD to do that for the next assignment.

Steps

  1. Build a Calculator class with an empty constructor and a method called addSymbol or something to that effect which accepts and returns a string. For now it will just return the accepted string.

Don't implement this now, but This method will be called when a symbol button is pressed (number or decimal), it will add that symbol to its internal member tracking the number entered into the calculator and then return a string representation of that number to be displayed

  1. Write 2 tests, 1 to test if the method works when used once to add a single character when nothing else has been added, and 1 to test when multiple consecutive strings are added. Run the tests.

The first test should pass, but the second test should fail.

  1. Implement that method in your calculator class.
  2. Continue in this manner. Build a test for a step you want to perform, say, adding a decimal. Think of all the potential use cases to cover ie: adding a single decimal, what if the number already has a decimal. Since the Calculator is part of a separate class, it shouldn't manipulate any UI instead, return the desired string to be displayed.

This calculator should have the following features:

  • Add numbers (in the future, you'll add them with buttons 0-9), but for now, just call the methods manually
  • Add a decimal to the current number
  • Remove the most recently added character (backspace)
  • Perform the following calculations
    • Addition
    • Subraction
    • Multiplication
    • Division
  • Perform repeated calculations (5 * 10 = 50, pressing equals again should return 500, etc.)
  • Clear all values

Be sure to add test cases for each use case on each feature before implementing that feature

Go Further

  • Add more functions to your calculator (square, square root, pi)

android_unittest_calculator's People

Contributors

chancepayne avatar

Watchers

 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.