React Native - State of the game

Anonymous
timer Asked: Jun 23rd, 2018
account_balance_wallet $20

Question description

Create a React Native app that keeps track of 2 teams scores.

The page should have the following

  • Score for team A
  • Score for team B
  • Button for Team A
  • Button for Team B

When the button for Team A is clicked, the score should go up for Team A

When the button for Team B is clicked, the score should go up for Team B

  • The App is required to use the state variable (look at BMI for examples of the state variable)

import React, { Component } from 'react'; import { Text, View, StyleSheet, Button, Alert } from 'react-native'; import { Constants } from 'expo'; export default class App extends Component { state={ count:1, action:'Click Me' } _handleButtonPress = () => { if (this.state.count>9){ Alert.alert("You Win") //update to game Over this.setState({ action:'Click Me', count:0, }) } else{ this.setState({ count:this.state.count+1 }); } }; render() { return ( { this.state.count}
import React, { Component } from 'react'; import { Text, View, StyleSheet, TextInput } from 'react-native'; import { Constants } from 'expo'; export default class App extends Component { state = { inputValueFT: 0, inputValueIN: 0, inputValueWT: 0 }; _handleTextChangeFT = inputValue => { this.setState({ inputValueFT:inputValue }); }; _handleTextChangeIN = inputValue => { this.setState({ inputValueIN:inputValue }); }; _handleTextChangeWT = inputValue => { this.setState({ inputValueWT:inputValue }); }; render() { var bmi=0; var ft2in=this.state.inputValueFT*12; var totalHeight=Number(ft2in)+Number(this.state.inputValueFT); bmi=703 * (this.state.inputValueWT/(totalHeight*totalHeight)); bmi=Number((bmi).toFixed(2)) if(!bmi){ bmi="" } return ( Calculate your BMI! Enter Height (FT) Enter Height (IN) Enter Weight (lbs) {bmi} ); } } const styles = StyleSheet.create({ inputs :{ flex:.5 }, inputcontainer :{ flex:1, flexDirection:'row' }, container: { flex: 1, alignItems: 'center', justifyContent: 'center', paddingTop: Constants.statusBarHeight, backgroundColor: '#ecf0f1', }, title: { margin: 24, fontSize: 18, fontWeight: 'bold', textAlign: 'center', color: '#34495e', }, results :{ flex:.5, fontSize:80, fontWeight:'bold' } });

Tutor Answer

WriterMorrisonFrank
School: Cornell University

If you need...

flag Report DMCA
Review

Anonymous
Totally impressed with results!! :-)

Similar Questions
Hot Questions
Related Tags

Brown University





1271 Tutors

California Institute of Technology




2131 Tutors

Carnegie Mellon University




982 Tutors

Columbia University





1256 Tutors

Dartmouth University





2113 Tutors

Emory University





2279 Tutors

Harvard University





599 Tutors

Massachusetts Institute of Technology



2319 Tutors

New York University





1645 Tutors

Notre Dam University





1911 Tutors

Oklahoma University





2122 Tutors

Pennsylvania State University





932 Tutors

Princeton University





1211 Tutors

Stanford University





983 Tutors

University of California





1282 Tutors

Oxford University





123 Tutors

Yale University





2325 Tutors