Skip to content

Commit

Permalink
added question constructors
Browse files Browse the repository at this point in the history
  • Loading branch information
nsakenov committed May 5, 2021
1 parent 9d44d6a commit d4150e3
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 10 deletions.
40 changes: 30 additions & 10 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'question.dart';

void main() => runApp(Quizzler());

Expand Down Expand Up @@ -26,16 +27,17 @@ class QuizPage extends StatefulWidget {
}

class _QuizPageState extends State<QuizPage> {
List<Icon> scoreKeeper = [
Icon(
Icons.check,
color: Colors.green,
),
Icon(
Icons.close,
color: Colors.red,
)
List<Icon> scoreKeeper = [];
int questionNumber = 0;

List<Question> questionBank = [
Question(q: 'You can lead a cow down stairs but not up stairs.', a: false),
Question(
q: 'Approximately one quarter of human bones are in the feet.',
a: true),
Question(q: 'A slug\'s blood is green.', a: true)
];

@override
Widget build(BuildContext context) {
return Column(
Expand All @@ -48,7 +50,8 @@ class _QuizPageState extends State<QuizPage> {
padding: EdgeInsets.all(15.0),
child: Center(
child: Text(
'This test is where the question text will go.',
'text',
// questions[questionNumber],
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 25.0,
Expand All @@ -72,8 +75,15 @@ class _QuizPageState extends State<QuizPage> {
),
),
onPressed: () {
bool correctAnswer = true; //answers[questionNumber];
if (correctAnswer == true) {
print('right');
} else {
print('wrong');
}
setState(() {
scoreKeeper.add(Icon(Icons.check, color: Colors.green));
questionNumber++;
});
},
),
Expand All @@ -92,6 +102,16 @@ class _QuizPageState extends State<QuizPage> {
),
),
onPressed: () {
bool correctAnswer = true; // answers[questionNumber];
if (correctAnswer == false) {
print('right');
} else {
print('wrong');
}
setState(() {
scoreKeeper.add(Icon(Icons.close, color: Colors.red));
questionNumber++;
});
//The user picked false.
},
),
Expand Down
9 changes: 9 additions & 0 deletions lib/question.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class Question {
String questionText;
bool questionAnswer;

Question({String q, bool a}) {
questionText = q;
questionAnswer = a;
}
}

0 comments on commit d4150e3

Please sign in to comment.