From 9c555bca7ba5a4e5396245b2086df89ded7e0c8c Mon Sep 17 00:00:00 2001 From: AlisaLinUwU Date: Sun, 26 Jan 2025 11:35:35 +0500 Subject: Initialize --- src/main/java/.DS_Store | Bin 0 -> 6148 bytes src/main/java/kahootgui/.DS_Store | Bin 0 -> 6148 bytes src/main/java/kahootgui/App.java | 25 ++++ src/main/java/kahootgui/Controller.java | 97 +++++++++++++++ src/main/java/kahootgui/Main.java | 9 ++ src/main/java/kahootgui/Questions.java | 25 ++++ src/main/resources/META-INF/MANIFEST.MF | 3 + src/main/resources/kahootgui/images/list.png | Bin 0 -> 15390 bytes src/main/resources/kahootgui/images/logo.png | Bin 0 -> 22534 bytes src/main/resources/kahootgui/images/search.png | Bin 0 -> 17770 bytes src/main/resources/kahootgui/main.fxml | 164 +++++++++++++++++++++++++ src/main/resources/kahootgui/styles/main.css | 10 ++ 12 files changed, 333 insertions(+) create mode 100644 src/main/java/.DS_Store create mode 100644 src/main/java/kahootgui/.DS_Store create mode 100644 src/main/java/kahootgui/App.java create mode 100644 src/main/java/kahootgui/Controller.java create mode 100644 src/main/java/kahootgui/Main.java create mode 100644 src/main/java/kahootgui/Questions.java create mode 100644 src/main/resources/META-INF/MANIFEST.MF create mode 100644 src/main/resources/kahootgui/images/list.png create mode 100644 src/main/resources/kahootgui/images/logo.png create mode 100644 src/main/resources/kahootgui/images/search.png create mode 100644 src/main/resources/kahootgui/main.fxml create mode 100644 src/main/resources/kahootgui/styles/main.css (limited to 'src/main') diff --git a/src/main/java/.DS_Store b/src/main/java/.DS_Store new file mode 100644 index 0000000..5008ddf Binary files /dev/null and b/src/main/java/.DS_Store differ diff --git a/src/main/java/kahootgui/.DS_Store b/src/main/java/kahootgui/.DS_Store new file mode 100644 index 0000000..09747aa Binary files /dev/null and b/src/main/java/kahootgui/.DS_Store differ diff --git a/src/main/java/kahootgui/App.java b/src/main/java/kahootgui/App.java new file mode 100644 index 0000000..5dae92b --- /dev/null +++ b/src/main/java/kahootgui/App.java @@ -0,0 +1,25 @@ +package kahootgui; + +import javafx.application.Application; +import javafx.fxml.FXMLLoader; +import javafx.scene.Parent; +import javafx.scene.Scene; +import javafx.stage.Stage; + +import java.util.Objects; + +public class App extends Application { + + @Override + public void start(Stage primaryStage) throws Exception { + Parent root = FXMLLoader.load(Objects.requireNonNull(getClass().getResource("main.fxml"))); + primaryStage.setTitle("Тесты по языка программирования"); + primaryStage.setScene(new Scene(root, 747, 460)); + primaryStage.show(); + } + + public static void main(String[] args) { + launch(args); + } + +} diff --git a/src/main/java/kahootgui/Controller.java b/src/main/java/kahootgui/Controller.java new file mode 100644 index 0000000..476f9f1 --- /dev/null +++ b/src/main/java/kahootgui/Controller.java @@ -0,0 +1,97 @@ +package kahootgui; + +import javafx.fxml.FXML; +import javafx.scene.control.Button; +import javafx.scene.control.RadioButton; +import javafx.scene.control.ToggleGroup; +import javafx.scene.text.Text; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +public class Controller { + + @FXML + private ToggleGroup answers; + + @FXML + private Text question_text; + + @FXML + private RadioButton radio_btn_1; + + @FXML + private RadioButton radio_btn_2; + + @FXML + private RadioButton radio_btn_3; + + @FXML + private RadioButton radio_btn_4; + + @FXML + private Button answerBtn; + + private final Questions[] questions = new Questions[] { + new Questions("В каком из вариантов представлен корректный формат вывода информации на экран?", new String[] {"Console.Write()", "console.log()", "print()", "System.out.println()"}), + new Questions("Какой тип данных отвечает за целые числа?", new String[] {"String", "Float", "Boolean", "Integer"}), + new Questions("Где правильно присвоено новое значение к многомерному массиву?", new String[] {"a(0)(0) = 1;", "a[0 0] = 1;", "a{0}{0} = 1;", "a[0][0] = 1;"}), + new Questions("Какой метод позволяет запустить программу на Java?", new String[] {"Основного метода нет", "С класса, что был написан первым и с методов что есть внутри него", "Любой, его можно задавать в настройках проекта", "С метода main в любом из классов"}), + new Questions("Каждый файл должен называется...", new String[] {"по имени первой библиотеки в нём", "по имени названия пакета", "как вам захочется", "по имени класса в нём"}), + new Questions("Сколько параметров может принимать функция?", new String[] {"5", "10", "20", "неограниченное количество"}) + }; + + private int nowQuestion = 0, correctAnswers; + private String nowCorrectAnswer; + + @FXML + public void initialize() { + nowCorrectAnswer = questions[nowQuestion].correctAnswer(); + + answerBtn.setOnAction(e -> { + RadioButton selectedRadioButton = (RadioButton) answers.getSelectedToggle(); + if(selectedRadioButton != null) { + String toogleGroupValue = selectedRadioButton.getText(); + + if(toogleGroupValue.equals(nowCorrectAnswer)) { + System.out.println("Верный ответ"); + correctAnswers++; + } else { + System.out.println("Не верный ответ"); + } + + // Это был последний вопрос + if(nowQuestion + 1 == questions.length) { + radio_btn_1.setVisible(false); + radio_btn_2.setVisible(false); + radio_btn_3.setVisible(false); + radio_btn_4.setVisible(false); + answerBtn.setVisible(false); + + question_text.setText("Вы ответили корректно на " + correctAnswers + " из " + questions.length + " вопросов!"); + } else { + nowQuestion++; + nowCorrectAnswer = questions[nowQuestion].correctAnswer(); + + question_text.setText(questions[nowQuestion].getQuestion()); + String[] answers = questions[nowQuestion].getAnswers(); + + + List intList = Arrays.asList(answers); + + Collections.shuffle(intList); + + radio_btn_1.setText(intList.get(0)); + radio_btn_2.setText(intList.get(1)); + radio_btn_3.setText(intList.get(2)); + radio_btn_4.setText(intList.get(3)); + + selectedRadioButton.setSelected(false); + } + + } + }); + } + +} diff --git a/src/main/java/kahootgui/Main.java b/src/main/java/kahootgui/Main.java new file mode 100644 index 0000000..bbcccb1 --- /dev/null +++ b/src/main/java/kahootgui/Main.java @@ -0,0 +1,9 @@ +package kahootgui; + +public class Main { + + public static void main(String[] args) { + App.main(args); + } + +} diff --git a/src/main/java/kahootgui/Questions.java b/src/main/java/kahootgui/Questions.java new file mode 100644 index 0000000..44bbe34 --- /dev/null +++ b/src/main/java/kahootgui/Questions.java @@ -0,0 +1,25 @@ +package kahootgui; + +public class Questions { + + private String question; + private String[] answers; + + public Questions(String question, String[] answers) { + this.question = question; + this.answers = answers; + } + + public String correctAnswer() { + return this.answers[answers.length - 1]; + } + + public String getQuestion() { + return question; + } + + public String[] getAnswers() { + return answers; + } + +} diff --git a/src/main/resources/META-INF/MANIFEST.MF b/src/main/resources/META-INF/MANIFEST.MF new file mode 100644 index 0000000..69fbd7c --- /dev/null +++ b/src/main/resources/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Main-Class: kahootgui.Main + diff --git a/src/main/resources/kahootgui/images/list.png b/src/main/resources/kahootgui/images/list.png new file mode 100644 index 0000000..abdde73 Binary files /dev/null and b/src/main/resources/kahootgui/images/list.png differ diff --git a/src/main/resources/kahootgui/images/logo.png b/src/main/resources/kahootgui/images/logo.png new file mode 100644 index 0000000..ddef2cf Binary files /dev/null and b/src/main/resources/kahootgui/images/logo.png differ diff --git a/src/main/resources/kahootgui/images/search.png b/src/main/resources/kahootgui/images/search.png new file mode 100644 index 0000000..00400c6 Binary files /dev/null and b/src/main/resources/kahootgui/images/search.png differ diff --git a/src/main/resources/kahootgui/main.fxml b/src/main/resources/kahootgui/main.fxml new file mode 100644 index 0000000..1bae894 --- /dev/null +++ b/src/main/resources/kahootgui/main.fxml @@ -0,0 +1,164 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/kahootgui/styles/main.css b/src/main/resources/kahootgui/styles/main.css new file mode 100644 index 0000000..90a7c9f --- /dev/null +++ b/src/main/resources/kahootgui/styles/main.css @@ -0,0 +1,10 @@ +.button:hover { + -fx-background-color: #383838!important; + -fx-border-color: #383838!important; + -fx-text-fill: #fff!important; +} + +.button:pressed { + -fx-scale-y: 0.95; + -fx-scale-x: 0.95; +} \ No newline at end of file -- cgit v1.2.3