Git Product home page Git Product logo

react-native-calculator's Introduction

Open in Codespaces

Lab 2

Your name: Benjamin Lin

Code base

Instead of starting from scratch, you will start with a code base for this lab. The code base was revised from some code generated by ChatGPT. You can change anything in the code base to achieve the desired functionality and design. However, it is your responsiblity to maintain the test cases and make sure that the tests can run.

Currently, there are 8 test cases prepared under the __test__ folder. Two testIDs are heavily used to construct the test cases. You can find where the two testIDs are placed in the CalculatorScreen.js file under the screens folder.

Functionality

You may play with the basic calculator on your cellphone. Your app should function the same as the basic calculator on your cellphone in terms of functionality. You are the one to find out what rules the basic calculator abides.

You may use eval() method in JavaScript as an easy approach to do the calculation, and achieve the functionality. For example, given a valid calculation formula as a string, the eval() method can do the calculation for you:

// should return 53
eval('3 + 5 * 10')

If you decide to go with this approach, you may also want to search online and read about why you should be careful with the eval() method.

You will need to address all possible edge cases and potential errors, such as:

  • a number divided by 0
  • a user attempting to type numbers with leading zeros (e.g., 3+005)
  • a user attempting to type neighboring operators (e.g., +/)

You will need to add a test case per scenario. Please note that this is not an exhaustive list.

Design

See the expected design in the design folder. Your calculator app should look as the following.

design

Please read more in the style guide about the specs of our design expectation. Please try your best to make your app look the same as the expected design.

An example of calculation with this design is as following:

design2 design2

To do

When you finish, please do the following:

  1. design and develop the application
  2. add your tests to cover all possible user error scenarios
  3. commit and push your code
  4. add your name to this README file (see above)
  5. capture how your app looks locally in the simulated app on your machine
  6. put the captured image in the design folder
  7. edit this README file to display your captured image here in this README file (see the above displayed expected design as an example)

react-native-calculator's People

Contributors

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