Advertisement
tamsenmckerley

>;)

Apr 22nd, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.87 KB | None | 0 0
  1. dear eshnom,
  2. pay me $20 and you can see the code
  3.  
  4.  
  5. 3.2.7
  6. import React, { Component } from 'react';
  7. import { AppRegistry, Text, View, StyleSheet, } from 'react-native';
  8. import { Constants } from 'expo';
  9.  
  10. export default class App extends Component {
  11. state = {
  12. myString: 'hello, world'
  13. }
  14.  
  15. sayLoudly = () => {
  16. this.setState ({
  17. myString: 'HELLO, WORLD' + '!'
  18. })
  19. }
  20. // Add the sayLoudly() function here that updates the state
  21. // the function should utilize .toUpperCase() to capitalize myString
  22. // the function should also add a '!' at the end of myString
  23.  
  24. render() {
  25. return (
  26. <View style={styles.container}>
  27. <Text
  28. style={styles.paragraph}
  29. onPress = {this.sayLoudly}
  30. >
  31. {this.state.myString}
  32. </Text>
  33. </View>
  34. );
  35. }
  36. }
  37.  
  38. const styles = StyleSheet.create({
  39. container: {
  40. flex: 1,
  41. alignItems: 'center',
  42. justifyContent: 'center',
  43. backgroundColor: 'white',
  44. },
  45. paragraph: {
  46. color: 'indigo',
  47. fontSize: 30,
  48. fontWeight: 'bold',
  49. textAlign: 'center',
  50. }
  51. });
  52.  
  53. 3.2.9
  54. import React, { Component } from 'react';
  55. import { AppRegistry, Text, View, TouchableHighlight, StyleSheet } from 'react-native';
  56. import { Constants } from 'expo';
  57.  
  58. export default class App extends Component {
  59. state = {
  60. teamOneScore: 0,
  61. teamTwoScore: 0,
  62. }
  63.  
  64. teamOneTouchdown = () => {
  65. this.setState({
  66. teamOneScore: this.state.teamOneScore + 7,
  67. })
  68. }
  69.  
  70. teamOneFieldGoal = () => {
  71. this.setState({
  72. teamOneScore: this.state.teamOneScore + 3,
  73. })
  74. }
  75.  
  76. teamTwoTouchdown = () => {
  77. this.setState({
  78. teamTwoScore: this.state.teamTwoScore + 7,
  79. })
  80. }
  81.  
  82. teamTwoFieldGoal = () => {
  83. this.setState({
  84. teamTwoScore: this.state.teamTwoScore + 3,
  85. })
  86. }
  87.  
  88. render() {
  89. return (
  90. <View style={styles.container}>
  91. <Text style={styles.paragraph}>
  92. FOOTBALL SCOREKEEPER
  93. </Text>
  94.  
  95. <View style={styles.buttonContainer}>
  96. <TouchableHighlight
  97. style={styles.button}
  98. onPress={this.teamOneTouchdown}
  99. >
  100. <Text style={styles.buttonText}>
  101. TEAM 1 TOUCHDOWN!
  102. </Text>
  103. </TouchableHighlight>
  104. <TouchableHighlight
  105. style={styles.button}
  106. onPress={this.teamOneFieldGoal}
  107. >
  108. <Text style={styles.buttonText}>
  109. TEAM 1 FIELD GOAL!
  110. </Text>
  111. </TouchableHighlight>
  112. </View>
  113.  
  114. <View style={styles.buttonContainer}>
  115. <TouchableHighlight
  116. style={styles.button}
  117. onPress={this.teamTwoTouchdown}
  118. >
  119. <Text style={styles.buttonText}>
  120. TEAM 2 TOUCHDOWN!
  121. </Text>
  122. </TouchableHighlight>
  123.  
  124. <TouchableHighlight
  125. style={styles.button}
  126. onPress={this.teamTwoFieldGoal}
  127. >
  128. <Text style={styles.buttonText}>
  129. TEAM 2 FIELD GOAL!
  130. </Text>
  131. </TouchableHighlight>
  132. </View>
  133.  
  134. <Text style={styles.paragraph}>
  135. Team 1: {this.state.teamOneScore}
  136. </Text>
  137.  
  138. <Text style={styles.paragraph}>
  139. Team 2: {this.state.teamTwoScore}
  140. </Text>
  141.  
  142. </View>
  143. );
  144. }
  145. }
  146.  
  147. const styles = StyleSheet.create({
  148. container: {
  149. flex: 1,
  150. alignItems: 'center',
  151. justifyContent: 'center',
  152. backgroundColor: 'green',
  153. },
  154. paragraph: {
  155. color: 'white',
  156. fontSize: 20,
  157. textAlign: 'center',
  158. fontWeight: 'bold',
  159. },
  160. buttonContainer: {
  161. flexDirection: 'row',
  162.  
  163. },
  164. button: {
  165. height: 50,
  166. width: 80,
  167. backgroundColor: 'green',
  168. borderColor: 'white',
  169. borderWidth: 1,
  170. alignItems: 'center',
  171. justifyContent: 'center',
  172. },
  173. buttonText: {
  174. color: 'white',
  175. fontSize: 10,
  176. },
  177. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement