Giter VIP home page Giter VIP logo

android_methods's Introduction

Android Functions

Survey

After completing this project, please fill out the survey found here

Requirements

  1. Write a guessing game where the user has to guess a secret number you will hard code as another data member (there is a challenge at the end to make this random). After every guess the program tells the user whether their number was too large or too small.

  2. Must include these methods
    a. fun checkGuess(guess: Int): Int
    i. check to see if the number is correct and return the result as an integer value

    b. fun updateUI(result: Int)
    i. this will perform all the tasks necessary to update the display once the result has been determined
    ii. use a switch statement inside of this method to determine what to display to the user based on the provided result.

Create an Android Studio Project

  1. Create a new Android Studio project
  2. Name the project "Guessing Game"
  3. Make sure that the target API level is below that of your testing environment.

Add Views to the App

  1. Open the app's activity_main.xml file.
  2. Change the parent viewgroup to a linear layout

Set the orientation attribute to vertical to best utilize the screen real estate

  1. Add TextViews as desired to communicate necessary information to the user
  2. Add an EditText view to get input from the user
  3. Add a Button so the user can submit their guess
  4. Add IDs to all the views that will need to be accessed in the code

Create a Listener for the Button

  1. Create a listener and event handler for the submit button in MainActivity.java
  2. In the click event method, retreive the number guessed by the user

int guess = Integer.parseInt(editEntry.getText().toString());

Process the User's Guess

  1. Create the methods above to process the user's guess and show them the result
  2. Call the checkGuess method and pass it's return value into the updateUI method.

Use the following constant values to communicate the results between methods
static final int CORRECT = 0;
static final int LOW = 1;
static final int HIGH = 2;
static final int RESET = 3;

Submit

Send your completed app to your Project Manager.

Challenge

Randomly generate a secret number.

use Random.nextInt(MAX_VALUE); // where MAX_VALUE < the highest number you want to generate
You'll need to import the kotlin.random.Random library for this to work Documentation located here

When the user has correctly guessed the number, allow them to reset and allow the user to try again.

Again, experiment with attributes of your textViews and other GUI components to improve the look of your app.

android_methods's People

Contributors

chancepayne avatar

Stargazers

 avatar

Watchers

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