13:05 ET Dow -154.48 at 10309.92, Nasdaq -37.61 at 2138.44, S&P -19.130 1 100001 0 1 0 1 1 0 1 0 00 0 1 1 1 0 1 100001 0 1 1 100001 0 1 100001 0 1 0 1 1 0 1 0 00 0 1 1 1 0 1 100001 0 1 1 100001 0 1 100001 0 1 0 1 1 0 1 0 00 0 1 1 1 0 1 100001 0 1 1 100001 0 1 100001 0 1 0 1 1 0 1 0 00 0 1 1 1 0 1 100001 0 1 1 100001 0 1 100001 0 1 0 1 1 0 1 0 00 0 1 1 1 0 1 100001 0 1 1 100001 0 1 100001 0 1 0 1 1 0 1 0 00 0 1 1 1 0 1 100001 0 1 1 100001 0 1 100001 0 1 0 1 1 0 1 0 00 0 1 1 1 0 1 100001 0 1 1 100001 0 1 100001 0 1 0 1 1 0 1 0 00 0 1 1 1 0 1 100001 0 1 1 100001 0 1 100001 0 1 0 1 1 0 1 0 00 0 1 1 1 0 1 100001 0 1 1 100001 0 1 100001 0 1 0 1 1 0 1 0 00 0 1 1 1 0 1 100001 0 1 1 100001 0 1 100001 0 1 0 1 1 0 1 0 00 0 1 1 1 0 1 100001 0 1 1 100001 0 1 100001 0 1 0 1 1 0 1 0 00 0 1 1 1 0 1 100001 0 1 1 100001 0 1 100001 0 1 0 1 1 0 1 0 00 0 1 1 1 0 1 100001 0 1 1 100001 0 1 100001 0 1 0 1 1 0 1 0 00 0 1 1 1 0 1 100001 0 1 1 100001 13:05 ET Dow -154.48 at 10309.92, Nasdaq -37.61 at 2138.44, S&P -19.1313:05 ET Dow -154.48 at 10309.92, Nasdaq -37.61 at 2138.44, S&P -19.13

.

.

Saturday, April 16, 2011

Android Development in C# Using Mono for Android & Microsoft Visual Studio – Ethan Castanon’s Math Games Source Code


using System;
using Android.App;
using Android.Content;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;
namespace biz.quantumsupport.mathgame
{
[Activity(Label = "Math Game 50", MainLauncher = true, Icon = "@drawable/icon")]
public class Activity1 : Activity
{
TextView lblCNumberProblemsRemaining, lblCpercentagecorrect, lblCfirstRandom, lblCsecondRandom, lblCusersAnswer, lblCandroidAnswer;
//Button btnC1, btnC2, btnC3, btnC4, btnC5, btnC6, btnC7, btnC8, btnC9, btnC0;
int intProblemsLeft, intUsersAnswer, x, y, z;
String strProblemsLeft, strUsersAnswer, strPercentRight, strAnswerBuilding;
Button btnStart;
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
// Set our view from the “main” layout resource
SetContentView(Resource.Layout.Main);
lblCandroidAnswer = FindViewById<TextView>(Resource.Id.lblVandroidsAnswer);
lblCusersAnswer = FindViewById<TextView>(Resource.Id.lblVusersAnswer);
//lblCNumberProblemsRemaining = FindViewById<TextView>(Resource.Id.lblVNumberProblemsRemaining);
lblCpercentagecorrect = FindViewById<TextView>(Resource.Id.lblVpercentagecorrect);
lblCfirstRandom = FindViewById<TextView>(Resource.Id.lblVfirstRandom);
lblCsecondRandom = FindViewById<TextView>(Resource.Id.lblVsecondRandom);
btnStart = FindViewById<Button>(Resource.Id.btnClear);
btnStart.Text = “Start”;
FindViewById(Resource.Id.btnEnter).Click += new EventHandler(this.OnClickEnter);
FindViewById(Resource.Id.btnClear).Click += new EventHandler(this.OnClickNext);
FindViewById(Resource.Id.btnClearAnswer).Click += new EventHandler(this.OnClickClear);
//Random firstRandomNumber = new Random();
//x = firstRandomNumber.Next() % 100;
//Random secondRandomNumber = new Random();
//y = secondRandomNumber.Next() % 100;
//String strFirstRandom = Convert.ToString(x);
//String strSecondRandom = Convert.ToString(y);
//lblCfirstRandom.Text = strFirstRandom;
//lblCsecondRandom.Text = strSecondRandom;
//z = x * y;
FindViewById(Resource.Id.btn0).Click += new EventHandler(this.OnClick0);
FindViewById(Resource.Id.btn1).Click += new EventHandler(this.OnClick1);
FindViewById(Resource.Id.btn2).Click += new EventHandler(this.OnClick2);
FindViewById(Resource.Id.btn3).Click += new EventHandler(this.OnClick3);
FindViewById(Resource.Id.btn4).Click += new EventHandler(this.OnClick4);
FindViewById(Resource.Id.btn5).Click += new EventHandler(this.OnClick5);
FindViewById(Resource.Id.btn6).Click += new EventHandler(this.OnClick6);
FindViewById(Resource.Id.btn7).Click += new EventHandler(this.OnClick7);
FindViewById(Resource.Id.btn8).Click += new EventHandler(this.OnClick8);
FindViewById(Resource.Id.btn9).Click += new EventHandler(this.OnClick9);
// end of the onCreate block
}
void OnClick1(Object sender, EventArgs e)
{
strAnswerBuilding += “1″;
lblCusersAnswer.Text = strAnswerBuilding;
}
void OnClick0(Object sender, EventArgs e)
{
strAnswerBuilding += “0″;
lblCusersAnswer.Text = strAnswerBuilding;
}
void OnClick2(Object sender, EventArgs e)
{
strAnswerBuilding += “2″;
lblCusersAnswer.Text = strAnswerBuilding;
}
void OnClick3(Object sender, EventArgs e)
{
strAnswerBuilding += “3″;
lblCusersAnswer.Text = strAnswerBuilding;
}
void OnClick4(Object sender, EventArgs e)
{
strAnswerBuilding += “4″;
lblCusersAnswer.Text = strAnswerBuilding;
}
void OnClick5(Object sender, EventArgs e)
{
strAnswerBuilding += “5″;
lblCusersAnswer.Text = strAnswerBuilding;
}
void OnClick6(Object sender, EventArgs e)
{
strAnswerBuilding += “6″;
lblCusersAnswer.Text = strAnswerBuilding;
}
void OnClick7(Object sender, EventArgs e)
{
strAnswerBuilding += “7″;
lblCusersAnswer.Text = strAnswerBuilding;
}
void OnClick8(Object sender, EventArgs e)
{
strAnswerBuilding += “8″;
lblCusersAnswer.Text = strAnswerBuilding;
}
void OnClick9(Object sender, EventArgs e)
{
strAnswerBuilding += “9″;
lblCusersAnswer.Text = strAnswerBuilding;
}
// j = the total number of questions
int j = 0;
// k = the number of questions correct
int k = 0;
String strJ;
String strK;
void OnClickEnter(Object sender, EventArgs e)
{
//
j = j + 1;
try
{
strUsersAnswer = lblCusersAnswer.Text.ToString();
intUsersAnswer = Convert.ToInt32(strUsersAnswer);
}
catch (Exception)
{
String strCatchProduct = Convert.ToString(z);
lblCandroidAnswer.Text = strCatchProduct;
strJ = Convert.ToString(j);
strK = Convert.ToString(k);
String strRightE = strK + “/” + strJ;
strPercentRight = strRightE;
lblCpercentagecorrect.Text = strPercentRight;
strAnswerBuilding = “”;
return;
}
// end of catch block
if (z == intUsersAnswer)
{
k = k + 1;
}
strUsersAnswer = lblCusersAnswer.Text.ToString();
intUsersAnswer = Convert.ToInt32(strUsersAnswer);
//l= (k/j)*100;
strJ = Convert.ToString(j);
strK = Convert.ToString(k);
String strRight = strK + “/” + strJ;
strPercentRight = strRight;
lblCpercentagecorrect.Text = strPercentRight;
//strProblemsLeft = Convert.ToString(i – 1);
String strProduct = Convert.ToString(z);
lblCandroidAnswer.Text = strProduct;
strAnswerBuilding = “”;
}
void OnClickNext(Object sender, EventArgs e)
{
Random firstRandomNumber = new Random();
x = firstRandomNumber.Next() % 51;
y = firstRandomNumber.Next() % 51;
Random secondRandomNumber = new Random();
//y = secondRandomNumber.Next() % 100;
String strFirstRandom = Convert.ToString(x);
String strSecondRandom = Convert.ToString(y);
lblCfirstRandom.Text = strFirstRandom;
lblCsecondRandom.Text = strSecondRandom;
z = x * y;
lblCandroidAnswer.Text = “”;
lblCusersAnswer.Text = “”;
btnStart.Text = “Next”;
strAnswerBuilding = “”;
}
void OnClickClear(Object sender, EventArgs e)
{
lblCusersAnswer.Text = “”;
strAnswerBuilding = “”;
}
}
}