Primary arithmetic app first sprint the next day

Source: Internet
Author: User

Team members: Chen Shuyun, Yang Jiane, Chen Xi

Team selection: Primary arithmetic App

First Sprint stage time: 11.17~11.27

This procedure is to solve the problem of last judgment, but there is a new problem page can not be adjusted, need to be improved

This improvement code is:

Import Java.util.random;import android.os.bundle;import Android.app.activity;import Android.view.menu;import Android.view.view;import Android.view.view.onclicklistener;import Android.widget.button;import Android.widget.edittext;import Android.widget.textview;import Android.widget.toast;public class CalculatorActivity Extends Activity {Private final random num1=new random ();p rivate final random num2=new random ();p rivate final random r = N EW Random ();p rivate char[] ch = {' + ', '-', ' * ', '/'}; Character array private int index = R.nextint (ch.length); Random number, less than the length of the array, 0~3private Char A=ch[index];p rivate TextView text1,text2,text3;private EditText answer;private Button surebutton;//OK button private string c;private string e;private string b;private int i1,i2,i3; @Overrideprotected void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate); Setcontentview (r.layout.activity_ Calculator); text1= (TextView) Findviewbyid (R.ID.TEXTVIEW1);//random number text2= (TextView) Findviewbyid (R.ID.TEXTVIEW2);// Op symbol text3= (TexTView) Findviewbyid (R.ID.TEXTVIEW3);//random number answer= (EditText) Findviewbyid (R.ID.EDITTEXT1);//Results B=answer.gettext ( ). toString ();//Gets the input value i1=integer.valueof (b); c=string.valueof (Num1.nextint); i1=integer.valueof (c); String d=string.valueof (a); e=string.valueof (Num2.nextint); i3=integer.valueof (e); Text1.settext (c);// Random number 1-100text2.settext (d);//random operator +,-, *,/text3.settext (e);//random number 1-100surebutton= (Button) Findviewbyid ( R.id.surebutton);//OK button Surebutton.setonclicklistener (new Onclicklistener () {@Overridepublic void OnClick (View arg0) {//TODO auto-generated Method Stubswitch (Index) {case 0:{if (I1==I2+I3) toast.maketext (calculatoractivity.this, "correct" +b , Toast.length_short). Show (); Elsetoast.maketext (calculatoractivity.this, "error" +b, Toast.length_short). Show (); break ;} Case 1:{if (I1==I2-I3) toast.maketext (calculatoractivity.this, "correct" +b, Toast.length_short). Show (); Elsetoast.maketext (calculatoractivity.this, "error" +b, Toast.length_short). Show (); break;} Case 2:{if (I1==I2*I3) Toast.maketext (calculatoractivity.thIS, "correct" +b, Toast.length_short). Show (); Elsetoast.maketext (calculatoractivity.this, "error" +b, Toast.length_short). Show (); break;} Case 3:{if (i3!=0) {if (i1== (I2/I3)) Toast.maketext (calculatoractivity.this, "correct" +b, Toast.length_short). Show (); Elsetoast.maketext (calculatoractivity.this, "error" +b, Toast.length_short). Show (); Break;}}});} @Overridepublic boolean Oncreateoptionsmenu (Menu menu) {//Inflate the menu; This adds items to the action bar if it is PR Esent.getmenuinflater (). Inflate (R.menu.calculator, menu); return true;}}

Failure, is trying to improve in!

Primary arithmetic app first sprint the next day

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.