public static bool isSecondAnswerCorrect(List <int> vars, GridValue[] gvArr, int numberOfVariables) { Log.Debug(TAG, "isSecondAnswerCorrect"); foreach (int i in vars) { Log.Debug(TAG, i + ""); } Log.Debug(TAG, "Mult: GvArr: upperLeftGV, upperRightGV, lowerLeftGV, lowerRightGV "); for (int i = 0; i < gvArr.Length; ++i) { Log.Debug(TAG, "GvArr:" + gvArr[i].ToString()); } if (Constants.ONE_VAR == numberOfVariables) { //For 1 variable Log.Debug(TAG, "One var"); int a = 0; int b = 0; int c = 0; //Should expand/change when checking for outer grids GridValue upLeft = gvArr[0]; GridValue upRight = gvArr[1]; GridValue downLeft = gvArr[2]; GridValue downRight = gvArr[3]; a = vars[0]; b = vars[1]; c = vars[2]; if (a == (upRight + downLeft - (upLeft + downRight)).x2Val && b == (upRight + downLeft - (upLeft + downRight)).xVal && c == (upRight + downLeft - (upLeft + downRight)).oneVal) { return(true); } else { return(false); } } else { Log.Debug(TAG, "Two var"); int a = 0; int b = 0; int c = 0; int d = 0; int e = 0; int f = 0; //Should expand/change when checking for outer grids GridValue upLeft = gvArr[0]; GridValue upRight = gvArr[1]; GridValue downLeft = gvArr[2]; GridValue downRight = gvArr[3]; a = vars[0]; //x2 b = vars[1]; //y2 c = vars[2]; //xy d = vars[3]; //x e = vars[4]; //y f = vars[5]; //one if (a == (upRight + downLeft - (upLeft + downRight)).x2Val && b == (upRight + downLeft - (upLeft + downRight)).y2Val && c == (upRight + downLeft - (upLeft + downRight)).xyVal && d == (upRight + downLeft - (upLeft + downRight)).xVal && e == (upRight + downLeft - (upLeft + downRight)).yVal && f == (upRight + downLeft - (upLeft + downRight)).oneVal) { return(true); } else { return(false); } } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); Window.AddFlags(WindowManagerFlags.Fullscreen); Window.ClearFlags(WindowManagerFlags.ForceNotFullscreen); ActionBar.Hide(); numberOfVariables = Intent.GetIntExtra(Constants.VARIABLE_COUNT, 0); SetContentView(Resource.Layout.MultiplyTwoVar); // Create your application here activityType = Constants.MULTIPLY; listeners = new Listeners(this); result = (TextView)FindViewById(Resource.Id.result); tile_1 = (AlgeTilesTextView)FindViewById(Resource.Id.tile_1); x_tile = (AlgeTilesTextView)FindViewById(Resource.Id.x_tile); y_tile = (AlgeTilesTextView)FindViewById(Resource.Id.y_tile); xy_tile = (AlgeTilesTextView)FindViewById(Resource.Id.xy_tile); x2_tile = (AlgeTilesTextView)FindViewById(Resource.Id.x2_tile); y2_tile = (AlgeTilesTextView)FindViewById(Resource.Id.y2_tile); tile_1.LongClick += listeners.tile_LongClick; x_tile.LongClick += listeners.tile_LongClick; y_tile.LongClick += listeners.tile_LongClick; x2_tile.LongClick += listeners.tile_LongClick; y2_tile.LongClick += listeners.tile_LongClick; xy_tile.LongClick += listeners.tile_LongClick; upperLeftGrid = FindViewById <AlgeTilesRelativeLayout>(Resource.Id.upperLeft); upperRightGrid = FindViewById <AlgeTilesRelativeLayout>(Resource.Id.upperRight); lowerLeftGrid = FindViewById <AlgeTilesRelativeLayout>(Resource.Id.lowerLeft); lowerRightGrid = FindViewById <AlgeTilesRelativeLayout>(Resource.Id.lowerRight); upperMiddleGrid = FindViewById <GridLayout>(Resource.Id.upperMiddle); middleLeftGrid = FindViewById <GridLayout>(Resource.Id.middleLeft); middleRightGrid = FindViewById <GridLayout>(Resource.Id.middleRight); lowerMiddleGrid = FindViewById <GridLayout>(Resource.Id.lowerMiddle); ViewTreeObserver vto2 = upperLeftGrid.ViewTreeObserver; vto2.GlobalLayout += (sender, e) => { if (!isFirstTime) { heightInPx = upperLeftGrid.Height; widthInPx = upperLeftGrid.Width; upperLeftGrid.SetMinimumHeight(0); upperLeftGrid.SetMinimumWidth(0); isFirstTime = true; LinearLayout.LayoutParams par_1 = (LinearLayout.LayoutParams)tile_1.LayoutParameters; TileUtilities.TileFactor tF = TileUtilities.getTileFactors(tile_1.getTileType()); par_1.Height = (int)(heightInPx / 7); par_1.Width = (int)(heightInPx / 7); tile_1.SetBackgroundResource(tF.id); tile_1.Text = tF.text; tile_1.LayoutParameters = par_1; LinearLayout.LayoutParams par_x = (LinearLayout.LayoutParams)x_tile.LayoutParameters; tF = TileUtilities.getTileFactors(x_tile.getTileType()); par_x.Height = (int)(heightInPx / tF.heightFactor); par_x.Width = (int)(heightInPx / 7); x_tile.SetBackgroundResource(tF.id); x_tile.Text = tF.text; x_tile.LayoutParameters = par_x; LinearLayout.LayoutParams par_y = (LinearLayout.LayoutParams)y_tile.LayoutParameters; tF = TileUtilities.getTileFactors(y_tile.getTileType()); par_y.Height = (int)(heightInPx / tF.heightFactor); par_y.Width = (int)(heightInPx / 7); y_tile.SetBackgroundResource(tF.id); y_tile.Text = tF.text; y_tile.LayoutParameters = par_y; LinearLayout.LayoutParams par_x2 = (LinearLayout.LayoutParams)x2_tile.LayoutParameters; tF = TileUtilities.getTileFactors(x2_tile.getTileType()); par_x2.Height = (int)(heightInPx / tF.heightFactor); par_x2.Width = (int)(heightInPx / tF.widthFactor); x2_tile.SetBackgroundResource(tF.id); if (tF.text.Length > 1 && !tF.text.Equals("xy")) { var cs = new SpannableStringBuilder(tF.text); cs.SetSpan(new SuperscriptSpan(), 1, 2, SpanTypes.ExclusiveExclusive); cs.SetSpan(new RelativeSizeSpan(0.75f), 1, 2, SpanTypes.ExclusiveExclusive); x2_tile.TextFormatted = cs; } else { x2_tile.Text = tF.text; } x2_tile.LayoutParameters = par_x2; LinearLayout.LayoutParams par_y2 = (LinearLayout.LayoutParams)y2_tile.LayoutParameters; tF = TileUtilities.getTileFactors(y2_tile.getTileType()); par_y2.Height = (int)(heightInPx / tF.heightFactor); par_y2.Width = (int)(heightInPx / tF.widthFactor); y2_tile.SetBackgroundResource(tF.id); if (tF.text.Length > 1 && !tF.text.Equals("xy")) { var cs = new SpannableStringBuilder(tF.text); cs.SetSpan(new SuperscriptSpan(), 1, 2, SpanTypes.ExclusiveExclusive); cs.SetSpan(new RelativeSizeSpan(0.75f), 1, 2, SpanTypes.ExclusiveExclusive); y2_tile.TextFormatted = cs; } else { y2_tile.Text = tF.text; } y2_tile.LayoutParameters = par_y2; LinearLayout.LayoutParams par_xy = (LinearLayout.LayoutParams)xy_tile.LayoutParameters; tF = TileUtilities.getTileFactors(xy_tile.getTileType()); par_xy.Height = (int)(heightInPx / tF.heightFactor); par_xy.Width = (int)(heightInPx / tF.widthFactor); xy_tile.SetBackgroundResource(tF.id); if (tF.text.Length > 1 && !tF.text.Equals("xy")) { var cs = new SpannableStringBuilder(tF.text); cs.SetSpan(new SuperscriptSpan(), 1, 2, SpanTypes.ExclusiveExclusive); cs.SetSpan(new RelativeSizeSpan(0.75f), 1, 2, SpanTypes.ExclusiveExclusive); xy_tile.TextFormatted = cs; } else { xy_tile.Text = tF.text; } xy_tile.LayoutParameters = par_xy; } }; outerGridLayoutList.Add(upperLeftGrid); outerGridLayoutList.Add(upperRightGrid); outerGridLayoutList.Add(lowerLeftGrid); outerGridLayoutList.Add(lowerRightGrid); innerGridLayoutList.Add(upperMiddleGrid); innerGridLayoutList.Add(middleLeftGrid); innerGridLayoutList.Add(middleRightGrid); innerGridLayoutList.Add(lowerMiddleGrid); //For multiply this is the initial grid available //Together form one Part of the formula upperMiddleGrid.Drag += listeners.GridLayout_Drag; lowerMiddleGrid.Drag += listeners.GridLayout_Drag; //Together form one Part of the formula middleLeftGrid.Drag += listeners.GridLayout_Drag; middleRightGrid.Drag += listeners.GridLayout_Drag; //Shade red the other grids for (int i = 0; i < outerGridLayoutList.Count; ++i) { outerGridLayoutList[i].SetBackgroundResource(Resource.Drawable.unavailable); } removeToggle = (ToggleButton)FindViewById(Resource.Id.remove); dragToggle = (ToggleButton)FindViewById(Resource.Id.drag); rotateToggle = (ToggleButton)FindViewById(Resource.Id.rotate); muteToggle = (ToggleButton)FindViewById(Resource.Id.mute); removeToggle.Click += listeners.toggle_click; dragToggle.Click += listeners.toggle_click; rotateToggle.Click += listeners.toggle_click; muteToggle.Click += listeners.toggle_click; tutorialButton = FindViewById <Button>(Resource.Id.tutorial); tutorialButton.Click += listeners.toggle_click; prefs = PreferenceManager.GetDefaultSharedPreferences(this); muteToggle.Checked = prefs.GetBoolean(Constants.MUTE, false); newQuestionButton = (Button)FindViewById <Button>(Resource.Id.new_question_button); refreshButton = (Button)FindViewById <Button>(Resource.Id.refresh_button); checkButton = (Button)FindViewById <Button>(Resource.Id.check_button); newQuestionButton.Click += button_click; refreshButton.Click += button_click; checkButton.Click += button_click; upperLeftGV = new GridValue(); upperRightGV = new GridValue(); lowerLeftGV = new GridValue(); lowerRightGV = new GridValue(); midUpGV = new GridValue(); midLowGV = new GridValue(); midLeftGV = new GridValue(); midRightGV = new GridValue(); gridValueList.Add(upperLeftGV); gridValueList.Add(upperRightGV); gridValueList.Add(lowerLeftGV); gridValueList.Add(lowerRightGV); gridValueList.Add(midUpGV); gridValueList.Add(midLowGV); gridValueList.Add(midLeftGV); gridValueList.Add(midRightGV); setupNewQuestion(); correct = MediaPlayer.Create(this, Resource.Raw.correct); incorrect = MediaPlayer.Create(this, Resource.Raw.wrong); x2ET = FindViewById <EditText>(Resource.Id.x2_value); y2ET = FindViewById <EditText>(Resource.Id.y2_value); xyET = FindViewById <EditText>(Resource.Id.xy_value); xET = FindViewById <EditText>(Resource.Id.x_value); yET = FindViewById <EditText>(Resource.Id.y_value); oneET = FindViewById <EditText>(Resource.Id.one_value); editTextList.Add(x2ET); editTextList.Add(y2ET); editTextList.Add(xyET); editTextList.Add(xET); editTextList.Add(yET); editTextList.Add(oneET); sv = FindViewById <ScrollView>(Resource.Id.sv); refreshScreen(Constants.MULTIPLY, gridValueList, innerGridLayoutList, outerGridLayoutList); rectTileListList.Add(upperRightRectTileList); rectTileListList.Add(upperLeftRectTileList); rectTileListList.Add(lowerLeftRectTileList); rectTileListList.Add(lowerRightRectTileList); settingsDialog = new Dialog(this); settingsDialog.Window.RequestFeature(WindowFeatures.NoTitle); }
public static bool isFirstAnswerCorrect(List <int> vars, GridValue[] gvArr, int numberOfVariables) { Log.Debug(TAG, "isFirstAnswerCorrect"); foreach (int i in vars) { Log.Debug(TAG, i + ""); } Log.Debug(TAG, "Mult: GvArr: midUpGV, midLowGV, midLeftGV, midRightGV"); for (int i = 0; i < gvArr.Length; ++i) { Log.Debug(TAG, "GvArr:" + gvArr[i].ToString()); } if (Constants.ONE_VAR == numberOfVariables) { //For 1 variable int a = 0; int b = 0; int c = 0; int d = 0; //Should expand/change when checking for outer grids GridValue midUp = gvArr[0]; GridValue midLo = gvArr[1]; GridValue midLeft = gvArr[2]; GridValue midRight = gvArr[3]; a = vars[0]; b = vars[1]; c = vars[2]; d = vars[3]; if ((a == (midUp - midLo).xVal && b == (midUp - midLo).oneVal) && (c == (midRight - midLeft).xVal && d == (midRight - midLeft).oneVal)) { return(true); } else if ((a == (midRight - midLeft).xVal && b == (midRight - midLeft).oneVal) && (c == (midUp - midLo).xVal && d == (midUp - midLo).oneVal)) { return(true); } else { return(false); } } else { int a = 0; int b = 0; int c = 0; int d = 0; int e = 0; int f = 0; //Should expand/change when checking for outer grids GridValue midUp = gvArr[0]; GridValue midLo = gvArr[1]; GridValue midLeft = gvArr[2]; GridValue midRight = gvArr[3]; a = vars[0]; //x b = vars[1]; //y c = vars[2]; //one d = vars[3]; //x e = vars[4]; //y f = vars[5]; //one if ((a == (midUp - midLo).xVal && b == (midUp - midLo).yVal && c == (midUp - midLo).oneVal) && (d == (midRight - midLeft).xVal && e == (midRight - midLeft).yVal && f == (midRight - midLeft).oneVal)) { return(true); } else if ((a == (midRight - midLeft).xVal && b == (midRight - midLeft).yVal && c == (midRight - midLeft).oneVal) && (d == (midUp - midLo).xVal && e == (midUp - midLo).yVal && f == (midUp - midLo).oneVal)) { return(true); } else { return(false); } } }