Added modulo 7 practice
This commit is contained in:
parent
0176a2f333
commit
e2e9c314af
4 changed files with 126 additions and 17 deletions
|
@ -3,6 +3,7 @@ import 'package:ohthatsa/pages/practice/PracticeSetup.dart';
|
|||
import 'package:ohthatsa/pages/practice/PracticeThing.dart';
|
||||
import 'package:ohthatsa/pages/practice/PracticeThingCentury.dart';
|
||||
import 'package:ohthatsa/pages/practice/PracticeThingLeap.dart';
|
||||
import 'package:ohthatsa/pages/practice/PracticeThingMod.dart';
|
||||
import 'package:ohthatsa/pages/practice/PracticeThingMonth.dart';
|
||||
import 'package:ohthatsa/AppDrawer.dart';
|
||||
import 'package:ohthatsa/pages/practice/PracticeType.dart';
|
||||
|
@ -44,6 +45,10 @@ class _PracticeState extends State<PracticePage> {
|
|||
this.practiceThing = PracticeThingLeap();
|
||||
break;
|
||||
}
|
||||
case (PracticeType.mod): {
|
||||
this.practiceThing = PracticeThingMod();
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
//
|
||||
}
|
||||
|
|
|
@ -107,23 +107,42 @@ class _PracticeSetupState extends State<PracticeSetupPage> {
|
|||
]
|
||||
),
|
||||
TableRow(
|
||||
children: <Widget>[
|
||||
FlatButton(
|
||||
child: Text("Leap"),
|
||||
color: Colors.blue,
|
||||
textColor: Colors.white,
|
||||
onPressed: () {
|
||||
Navigator.pushNamed(
|
||||
context,
|
||||
'/practice/practice',
|
||||
arguments: PracticeSetup(_count, _showCorrect, PracticeType.leap)
|
||||
);
|
||||
},
|
||||
),
|
||||
Text("80%", textAlign: TextAlign.center, style: TextStyle(fontSize: 25)),
|
||||
Text("70%", textAlign: TextAlign.center, style: TextStyle(fontSize: 25)),
|
||||
Text("50%", textAlign: TextAlign.center, style: TextStyle(fontSize: 25))
|
||||
]
|
||||
children: <Widget>[
|
||||
FlatButton(
|
||||
child: Text("Leap"),
|
||||
color: Colors.blue,
|
||||
textColor: Colors.white,
|
||||
onPressed: () {
|
||||
Navigator.pushNamed(
|
||||
context,
|
||||
'/practice/practice',
|
||||
arguments: PracticeSetup(_count, _showCorrect, PracticeType.leap)
|
||||
);
|
||||
},
|
||||
),
|
||||
Text("80%", textAlign: TextAlign.center, style: TextStyle(fontSize: 25)),
|
||||
Text("70%", textAlign: TextAlign.center, style: TextStyle(fontSize: 25)),
|
||||
Text("50%", textAlign: TextAlign.center, style: TextStyle(fontSize: 25))
|
||||
]
|
||||
),
|
||||
TableRow(
|
||||
children: <Widget>[
|
||||
FlatButton(
|
||||
child: Text("Modulo 7"),
|
||||
color: Colors.blue,
|
||||
textColor: Colors.white,
|
||||
onPressed: () {
|
||||
Navigator.pushNamed(
|
||||
context,
|
||||
'/practice/practice',
|
||||
arguments: PracticeSetup(_count, _showCorrect, PracticeType.mod)
|
||||
);
|
||||
},
|
||||
),
|
||||
Text("80%", textAlign: TextAlign.center, style: TextStyle(fontSize: 25)),
|
||||
Text("70%", textAlign: TextAlign.center, style: TextStyle(fontSize: 25)),
|
||||
Text("50%", textAlign: TextAlign.center, style: TextStyle(fontSize: 25))
|
||||
]
|
||||
),
|
||||
TableRow(
|
||||
children: <Widget>[
|
||||
|
|
84
lib/pages/practice/PracticeThingMod.dart
Normal file
84
lib/pages/practice/PracticeThingMod.dart
Normal file
|
@ -0,0 +1,84 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:ohthatsa/pages/practice/PracticeAnswer.dart';
|
||||
import 'package:ohthatsa/pages/practice/PracticeThing.dart';
|
||||
import 'package:ohthatsa/pages/practice/PracticeType.dart';
|
||||
|
||||
class PracticeThingMod extends PracticeThing {
|
||||
int current;
|
||||
|
||||
PracticeThingMod() {
|
||||
next();
|
||||
}
|
||||
|
||||
@override
|
||||
bool answer(int answer) {
|
||||
answers.add(PracticeAnswer(current, answer, PracticeType.mod));
|
||||
final correctAnswer = current % 7;
|
||||
return answer == correctAnswer;
|
||||
}
|
||||
|
||||
@override
|
||||
void next() {
|
||||
current = random.nextInt(141);
|
||||
}
|
||||
|
||||
@override
|
||||
Text getAppBarTitleText() {
|
||||
return Text("Practicing Modulo");
|
||||
}
|
||||
|
||||
@override
|
||||
List<bool> getBoolAnswers() {
|
||||
return answers.map((answer) =>
|
||||
answer.question % 7 == answer.answer
|
||||
).toList();
|
||||
}
|
||||
|
||||
Text getCurrentQuestionText(){
|
||||
return Text(
|
||||
current.toString(),
|
||||
style: TextStyle(
|
||||
fontSize: 30
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
Text getLastAnswerText(bool showCorrect){
|
||||
String text = "-";
|
||||
Color color = Colors.red;
|
||||
if(answers.length >= 1){
|
||||
final answer = answers[answers.length - 1];
|
||||
final correctAnswer = answer.question % 7;
|
||||
text = answer.question.toString() + (showCorrect ? ": $correctAnswer" : "");
|
||||
if(answer.answer == correctAnswer){
|
||||
color = Colors.green;
|
||||
}
|
||||
}
|
||||
return Text(
|
||||
text,
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
color: color
|
||||
)
|
||||
);
|
||||
}
|
||||
Text getSecondLastAnswerText(bool showCorrect){
|
||||
String text = "-";
|
||||
Color color = Colors.red;
|
||||
if(answers.length >= 2){
|
||||
final answer = answers[answers.length - 2];
|
||||
final correctAnswer = answer.question % 7;
|
||||
text = answer.question.toString() + (showCorrect ? ": $correctAnswer" : "");
|
||||
if(answer.answer == correctAnswer){
|
||||
color = Colors.green;
|
||||
}
|
||||
}
|
||||
return Text(
|
||||
text,
|
||||
style: TextStyle(
|
||||
fontSize: 10,
|
||||
color: color
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
|
@ -2,5 +2,6 @@ enum PracticeType {
|
|||
month,
|
||||
century,
|
||||
leap,
|
||||
mod,
|
||||
all
|
||||
}
|
Loading…
Add table
Reference in a new issue