start lab11
This commit is contained in:
5 files changed
+205
-2
No files matched your search
+2
-1
@@ -9,5 +9,6 @@
|
|||||||
</content>
|
</content>
|
||||||
<orderEntry type="jdk" jdkName="24" jdkType="JavaSDK" />
|
<orderEntry type="jdk" jdkName="24" jdkType="JavaSDK" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
<orderEntry type="library" name="lib" level="project" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
||||||
+1
-1
@@ -1 +1 @@
|
|||||||
COUNTRY=14
|
COUNTRY=9
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
Who holds the record for the most Formula One World Drivers’ Championships?|Lewis Hamilton,Michael Schumacher
|
||||||
|
Which team has won the most Constructors’ Championships in Formula One history?|Ferrari
|
||||||
|
What year was the first Formula One championship?|1950
|
||||||
|
Which driver is known as ‘The Professor’?|Alain Prost
|
||||||
|
At which circuit is the Monaco Grand Prix held?|Circuit de Monaco,Monte Carlo
|
||||||
|
What is the oldest race track on the modern F1 calendar?|Monza
|
||||||
|
Who is the youngest driver to start a Formula One race?|Max Verstappen
|
||||||
|
Which team did Ayrton Senna win all three of his championships with?|McLaren
|
||||||
|
What do the initials DRS stand for in Formula One?|Drag Reduction System
|
||||||
|
Which driver has the most pole positions in Formula One?|Lewis Hamilton
|
||||||
|
Who won the 2021 Formula One World Championship?|Max Verstappen
|
||||||
|
What tyre supplier currently serves Formula One?|Pirelli
|
||||||
|
Which country hosts the Suzuka Circuit?|Japan
|
||||||
|
What is the name of Ferrari’s Formula One team?|Scuderia Ferrari
|
||||||
|
What is the maximum number of drivers allowed per team in a season?|Two,2
|
||||||
|
What are race weekends usually called?|Grand Prix
|
||||||
|
Which circuit is famous for the Eau Rouge–Raidillon uphill complex?|Spa-Francorchamps,Spa
|
||||||
|
Who is the longest-serving team principal in modern F1?|Christian Horner
|
||||||
|
Which city hosts the F1 night race first introduced in 2008?|Singapore
|
||||||
|
Which driver earned the nickname ‘Iceman’?|Kimi Raikkonen
|
||||||
|
Which team introduced the ‘double diffuser’ controversy in 2009?|Brawn GP
|
||||||
|
Who won the first race of the hybrid V6 turbo era in 2014?|Nico Rosberg
|
||||||
|
Which circuit is the longest track currently in F1?|Spa-Francorchamps,Spa
|
||||||
|
Which nation has produced the most Formula One World Champions?|The United Kingdom,United Kingdom,UK,The UK
|
||||||
|
What is the governing body of Formula One?|The FIA,FIA
|
||||||
|
How many points are awarded for a race win under the current system?|25
|
||||||
|
Which team did Michael Schumacher win five consecutive titles with?|Ferrari
|
||||||
|
Which country hosted the first Formula One race in the Middle East?|Bahrain
|
||||||
|
What is the term for the gap between two cars in qualifying?|Delta time
|
||||||
|
What power unit configuration do modern F1 cars use?|1.6-liter V6 turbo-hybrid,V6,V6 turbo hybrid,V6 turbo-hybrid,v6 engine
|
||||||
|
Which race is known as ‘The Temple of Speed’?|The Italian Grand Prix,Monza
|
||||||
|
Who won the first Constructors’ Championship in 1958?|Vanwall
|
||||||
|
Which British circuit is the ‘home of the British Grand Prix’?|Silverstone
|
||||||
|
Who is the youngest World Champion in history?|Sebastian Vettel
|
||||||
|
Which team did Lewis Hamilton debut with?|McLaren
|
||||||
|
Which driver famously said, ‘If you no longer go for a gap, you’re no longer a racing driver’?|Ayrton Senna
|
||||||
|
Which Grand Prix was added as the first U.S. street race in 2022?|The Miami Grand Prix,Miami Grand Prix,Miami
|
||||||
|
What does a red flag mean?|session stopped
|
||||||
|
Which Formula One team is based in Milton Keynes, UK?|Red Bull Racing,Red Bull,RedBull,Redbull racing
|
||||||
|
What is the fastest pit stop in F1 history?|1.8,1.8 seconds
|
||||||
|
Who won the dramatic 2008 Brazilian Grand Prix to secure his first title?|Lewis Hamilton
|
||||||
|
Which team did Max Verstappen join after Toro Rosso?|Red Bull Racing,Red Bull,RedBull,Redbull racing
|
||||||
|
Which constructor dominated the early hybrid era (2014–2020)?|Mercedes
|
||||||
|
What material is an F1 monocoque predominantly made from?|Carbon fiber
|
||||||
|
What is the name of the circuit COTA?|Circuit of the Americas
|
||||||
|
Which team was formerly known as Racing Point?|Aston Martin
|
||||||
|
Which F1 driver won the 2016 World Championship?|Nico Rosberg
|
||||||
|
Which track has the fewest corners?|Monza
|
||||||
|
Which constructor did Ayrton Senna finish his career with?|Williams
|
||||||
|
Which flag indicates the race is over?|The checkered flag,checkered flag,checkered
|
||||||
|
Who became Ferrari’s youngest race winner in 2019?|Charles Leclerc
|
||||||
|
Which circuit features the famous ‘Wall of Champions’?|Circuit Gilles Villeneuve
|
||||||
|
Which race uses the longest DRS zone?|the Mexican Grand Prix
|
||||||
|
Who won the 2022 World Championship?|Max Verstappen
|
||||||
|
Which driver has the most career race starts?|Fernando Alonso
|
||||||
|
What does VSC stand for?|Virtual Safety Car
|
||||||
|
Who is the most successful British F1 driver in terms of wins?|Lewis Hamilton
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
package ca.bcit.comp2522.lab11;
|
||||||
|
|
||||||
|
public class Question
|
||||||
|
{
|
||||||
|
private static final int MIN_ANSWERS = 1;
|
||||||
|
|
||||||
|
private final String question;
|
||||||
|
private final String[] answers;
|
||||||
|
|
||||||
|
private static void validateString(final String str)
|
||||||
|
{
|
||||||
|
if (str == null || str.isBlank())
|
||||||
|
{
|
||||||
|
throw new IllegalArgumentException("Invalid string");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Question(
|
||||||
|
final String question,
|
||||||
|
final String[] answers
|
||||||
|
) {
|
||||||
|
validateString(question);
|
||||||
|
|
||||||
|
if (answers.length < MIN_ANSWERS)
|
||||||
|
{
|
||||||
|
throw new IllegalArgumentException("Answers must not be empty");
|
||||||
|
}
|
||||||
|
|
||||||
|
for (final String answer : answers)
|
||||||
|
{
|
||||||
|
validateString(answer);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.question = question;
|
||||||
|
this.answers = answers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getQuestion()
|
||||||
|
{
|
||||||
|
return this.question;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String[] getAnswers()
|
||||||
|
{
|
||||||
|
return this.answers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean validateAnswer(final String userAnswer)
|
||||||
|
{
|
||||||
|
for (final String answer : this.answers)
|
||||||
|
{
|
||||||
|
if (answer.equals(userAnswer))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,85 @@
|
|||||||
|
package ca.bcit.comp2522.lab11;
|
||||||
|
|
||||||
|
import javafx.application.Application;
|
||||||
|
import javafx.scene.Scene;
|
||||||
|
import javafx.scene.layout.VBox;
|
||||||
|
import javafx.stage.Stage;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.FileReader;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
public class Quiz extends Application
|
||||||
|
{
|
||||||
|
private static final int WIDTH = 800;
|
||||||
|
private static final int HEIGHT = 600;
|
||||||
|
private static final int QUESTION_SPLIT = 0;
|
||||||
|
private static final int ANSWER_SPLIT = 1;
|
||||||
|
private static final String DELIMITER = "\\|";
|
||||||
|
private static final int NUM_QUESTIONS = 10;
|
||||||
|
|
||||||
|
private final List<Question> questions = new ArrayList<>();
|
||||||
|
private Question current;
|
||||||
|
|
||||||
|
private void readQuestions(final String file)
|
||||||
|
{
|
||||||
|
final BufferedReader reader;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
reader = new BufferedReader(new FileReader(file));
|
||||||
|
|
||||||
|
String line;
|
||||||
|
while ((line = reader.readLine()) != null)
|
||||||
|
{
|
||||||
|
final String question;
|
||||||
|
final String[] answers;
|
||||||
|
|
||||||
|
question = line.split(DELIMITER)[QUESTION_SPLIT];
|
||||||
|
answers = line.split(DELIMITER)[ANSWER_SPLIT].split(",");
|
||||||
|
|
||||||
|
questions.add(new Question(
|
||||||
|
question,
|
||||||
|
answers
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (final FileNotFoundException e)
|
||||||
|
{
|
||||||
|
System.out.println("Unable to open file: " + file);
|
||||||
|
}
|
||||||
|
catch (final IOException e)
|
||||||
|
{
|
||||||
|
System.out.println("Error reading file: " + file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void start(final Stage stage)
|
||||||
|
{
|
||||||
|
final Scene scene;
|
||||||
|
final VBox root;
|
||||||
|
|
||||||
|
root = new VBox();
|
||||||
|
root.setPrefSize(WIDTH, HEIGHT);
|
||||||
|
scene = new Scene(root);
|
||||||
|
|
||||||
|
this.current = this.questions.get(new Random().nextInt(this.questions.size()));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
readQuestions("./data/quiz.txt");
|
||||||
|
|
||||||
|
stage.setScene(scene);
|
||||||
|
stage.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(final String[] args)
|
||||||
|
{
|
||||||
|
launch(args);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user