-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJavapage.dart
162 lines (146 loc) · 6.13 KB
/
Javapage.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
import 'package:quizzapp/FailPage.dart';
import 'package:quizzapp/QuestionsC.dart';
import 'package:quizzapp/PassPage.dart';
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
class java extends StatefulWidget {
@override
State<java> createState() => _javaState();
}
class _javaState extends State<java> {
List<IconData> scoreKeeper =[];
List<Questions> questionsBank=[
Questions(q: ' Binary search can be performed on an unsorted array in logarithmic time complexity', a: false),
Questions(q: ' In Python, the pass statement does nothing and is often used as a placeholder', a: true),
Questions(q: ' Object-oriented programming (OOP) is a programming paradigm that focuses on using classes and objects to design and build applications. ', a: true),
Questions(q: ' Recursion is always more memory-efficient than iteration in programming', a: false),
Questions(q: ' Recursion is always more memory-efficient than iteration in programming', a: true),
Questions(q: ' SQL injection is a technique where malicious SQL statements are inserted into an application\'s input fields to manipulate the database', a: true),
Questions(q: ' The Big O notation is used to describe the worst-case time complexity of an algorithm', a: true),
Questions(q: ' IPv6 addresses are 128 bits long and are represented in hexadecimal notation', a: true),
Questions(q: ' In JavaScript, the == operator performs type coercion, while the === operator performs strict equality checking', a: true),
Questions(q: ' The "Monty Hall problem" is a probability puzzle that involves selecting a prize from three doors, and switching doors after one is revealed', a: true),
];
int questionnumber=0;
int totalnumber=0;
int t=0;
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.black,
body: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
Expanded(
flex:5,
child: Padding(
padding:EdgeInsets.all(10) ,
child: Center(
child: Text(
questionsBank[questionnumber].questiontext,
textAlign: TextAlign.center,
style:GoogleFonts.rajdhani(fontSize: 30,color: Colors.white,
),
),
),
),
),
Card(
color:Colors.green,
child: FloatingActionButton(
backgroundColor:Colors.green,
elevation: 0,
child:Text(
'True',
textAlign: TextAlign.center,
style:GoogleFonts.rajdhani(fontSize: 25,color: Colors.white,fontWeight: FontWeight.bold
),
),
onPressed: (){
bool correctans =questionsBank[questionnumber].questionanswer;
if (correctans==true){
t=t+1;
scoreKeeper.add(Icons.check);
}
else {
t=t;
scoreKeeper.add(Icons.close);
}
setState(() {
questionnumber++;
print('questionnumber: $questionnumber');
print('t: $t');
if (questionnumber == questionsBank.length-1 )
{
if( t >7 || t<10) {
Navigator.push(context,
MaterialPageRoute(
builder: (context) => PassPage()));
} else if ( t<7 ) {
Navigator.push(context,
MaterialPageRoute(
builder: (context) => FailPage()));
}else{}
}});
},
),
),
Card(
color:Colors.red,
child: FloatingActionButton(
backgroundColor:Colors.red,
child:Text(
'False',
textAlign: TextAlign.center,
style:GoogleFonts.rajdhani(fontSize: 25,color: Colors.white,fontWeight: FontWeight.bold
),
),
elevation: 0,
onPressed: (){
bool correctans =questionsBank[questionnumber].questionanswer;
if (correctans==false){
t=t+1;
scoreKeeper.add(Icons.check);}
else {
t=t;
scoreKeeper.add(Icons.close);
}
setState(() {
questionnumber++;
print('questionnumber: $questionnumber');
print('t: $t');
if (questionnumber == questionsBank.length-1 ){
if( t<7 ) {
Navigator.push(context,
MaterialPageRoute(
builder: (context) => FailPage()));
} else if( t >7 || t<10) {
Navigator.push(context,
MaterialPageRoute(
builder: (context) => PassPage()));
} else{ }}
});},
),
),
Row(
children: scoreKeeper.map((iconData) {
if (iconData == Icons.check) {
return Icon(
iconData,
color: Colors.green, // Change this to the desired color for correct answers
);
} else if (iconData == Icons.close) {
return Icon(
iconData,
color: Colors.red, // Change this to the desired color for incorrect answers
);
}
return Container(); // Return an empty container if the iconData is invalid
}).toList(),
)
],
),
);
}
}