working year practice thing
This commit is contained in:
parent
7ffd19c7f1
commit
9d2b636d7d
4 changed files with 96 additions and 0 deletions
|
@ -9,6 +9,7 @@ import 'package:ohthatsa/pages/practice/thing/PracticeThingMod.dart';
|
|||
import 'package:ohthatsa/pages/practice/thing/PracticeThingMonth.dart';
|
||||
import 'package:ohthatsa/AppDrawer.dart';
|
||||
import 'package:ohthatsa/pages/practice/PracticeType.dart';
|
||||
import 'package:ohthatsa/pages/practice/thing/PracticeThingYear.dart';
|
||||
import 'package:ohthatsa/util/Extensions.dart';
|
||||
import 'package:sqflite/sqflite.dart';
|
||||
|
||||
|
@ -42,6 +43,10 @@ class _PracticeState extends State<PracticePage> {
|
|||
this.practiceThing = PracticeThingMonth();
|
||||
break;
|
||||
}
|
||||
case (PracticeType.year): {
|
||||
this.practiceThing = PracticeThingYear();
|
||||
break;
|
||||
}
|
||||
case (PracticeType.century): {
|
||||
this.practiceThing = PracticeThingCentury();
|
||||
break;
|
||||
|
|
|
@ -122,6 +122,7 @@ class _PracticeSetupState extends State<PracticeSetupPage> {
|
|||
]
|
||||
),
|
||||
getStatTableRow(snapshot, PracticeType.month),
|
||||
getStatTableRow(snapshot, PracticeType.year),
|
||||
getStatTableRow(snapshot, PracticeType.century),
|
||||
getStatTableRow(snapshot, PracticeType.leap),
|
||||
getStatTableRow(snapshot, PracticeType.mod),
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
enum PracticeType {
|
||||
month,
|
||||
year,
|
||||
century,
|
||||
leap,
|
||||
mod,
|
||||
|
|
89
lib/pages/practice/thing/PracticeThingYear.dart
Normal file
89
lib/pages/practice/thing/PracticeThingYear.dart
Normal file
|
@ -0,0 +1,89 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:ohthatsa/pages/practice/PracticeAnswer.dart';
|
||||
import 'package:ohthatsa/pages/practice/thing/PracticeThing.dart';
|
||||
import 'package:ohthatsa/util/DayCalculator.dart';
|
||||
|
||||
class PracticeThingYear extends PracticeThing {
|
||||
int current;
|
||||
|
||||
PracticeThingYear() {
|
||||
next();
|
||||
}
|
||||
|
||||
@override
|
||||
bool isCorrect(int answer){
|
||||
final correctAnswer = DayCalculator.getYearValue(current);
|
||||
return answer == correctAnswer;
|
||||
}
|
||||
|
||||
@override
|
||||
bool answer(int answer){
|
||||
final isCorrect = this.isCorrect(answer);
|
||||
answers.add(PracticeAnswer(current, answer, isCorrect));
|
||||
return isCorrect;
|
||||
}
|
||||
|
||||
@override
|
||||
void next() {
|
||||
current = 1700 + random.nextInt(500);
|
||||
}
|
||||
|
||||
List<bool> getBoolAnswers() {
|
||||
return answers.map((answer) =>
|
||||
answer.correct
|
||||
).toList();
|
||||
}
|
||||
|
||||
Text getAppBarTitleText() {
|
||||
return Text("Practicing Years");
|
||||
}
|
||||
|
||||
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 = DayCalculator.getYearValue(answer.question);
|
||||
text = answer.question.toString() + (showCorrect ? ": $correctAnswer" : "");
|
||||
if(answer.correct){
|
||||
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 = DayCalculator.getYearValue(answer.question);
|
||||
text = answer.question.toString() + (showCorrect ? ": $correctAnswer" : "");
|
||||
if(answer.correct){
|
||||
color = Colors.green;
|
||||
}
|
||||
}
|
||||
return Text(
|
||||
text,
|
||||
style: TextStyle(
|
||||
fontSize: 10,
|
||||
color: color
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue