Code Monkey home page Code Monkey logo

tipcalculator-project's Introduction

TipCalculator-project

DUE: 9 Mar 2021

Instructions:

Create an app that takes an input for an amount, an input for number of people spliting the check, a series of radio buttons for pre-determined tip amounts with the last radio button allowing for custom tip ammount, a button to reset the values, and a button to calculate the tip. The Button to calculate should send user to another Activity that only displays a tip amount summary and a Button that sends the user back to the Main Activity. The amounts (tip, total, and total per person) must be displayed as a TextView. All values must retain its state when the phone is rotated between portrait and landscape modes or any other instances where the app cycles through the activity lifecycle. There should be no values, such as strings, dimensions, etc. hardcoded in the .java files. They should be maintained and accessed from the appropriate resource files. An error message should be displayed to the user if they try to input a bill amount less than $1, total people less than 1, or a tip percentage less than 1%. Wow factor code to display an error message is provided in this README.

Error Message Code:

  Shows the error message in an alert dialog

  @param errorMessage
             String the error message to show
  @param fieldId
             the Id of the field which caused the error.
             This is required so that the focus can be
             set on that field once the dialog is
             dismissed.
 
private void showErrorAlert(String errorMessage, final int fieldId) {
    new AlertDialog.Builder(this)
            .setTitle("Error")
            .setMessage(errorMessage)
            .setNeutralButton("Close",
                    new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog,
                                            int which) {
                            findViewById(fieldId).requestFocus();
                        }
                    }).show();
}

Key Listener Code:

  KeyListener for the Total Amount, No of People and Other Tip Percentage
  fields. We need to apply this key listener to check for following
  conditions:
 
  1) If user selects Other tip percentage, then the other tip text field
  should have a valid tip percentage entered by the user. Enable the
  Calculate button only when user enters a valid value.
 
  2) If user does not enter values in the Total Amount and No of People,
  we cannot perform the calculations. Hence enable the Calculate button
  only when user enters a valid values.
  
  You will need to add code to the case statements in the switch block.
 
 private OnKeyListener mKeyListener = new OnKeyListener() {
    @Override
    public boolean onKey(View v, int keyCode, KeyEvent event) {

        switch (v.getId()) {
            case R.id.txtAmount:
            case R.id.txtPeople:
            case R.id.txtTipOther:
        }
        return false;
    }

};

Feel free to use any Layout you want. ConstrainLayout is a good option, but you may want to experiment with others, such as LinearLayout or TableLayout.

TODO:

  1. Open Android Studio and create an Android project named TipCalculator-<Your Last Name>.
  2. Edit .gitignore file and put the neccessary file names that do not belong in GitHub.
  3. Initialize project as a Git repoistory.
  4. Fork this project into your Github account and copy the clone link.
  5. Run the git remote add command to link your project to the Github repository.
  6. Perform a git pull origin master command to pull the README and sync the repos.
  7. Add,Commmit, and Push your initial files.
  8. Verify files were uploaded to your GitHub account.
  9. Complete the project.
  10. Commit and Push your completed project code to GitHub.

Grading:

The above requirements are for a 'B'. In order to achieve an 'A', then you must implement a WOW factor. This is normally something that you will have to think of and research how to do it yourself. For this first assignment, styling would be considered.

Note: Any issues you have with either the GitHub steps or Java/Android questions should be asked publically on Slack. If you have a question, chances are someone else does also. If you see someone has posted a question on Slack and you know the answer, please chime in and answer.

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.