diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..5c98b42
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,2 @@
+# Default ignored files
+/workspace.xml
\ No newline at end of file
diff --git a/.idea/artifacts/AnalogClock.xml b/.idea/artifacts/AnalogClock.xml
new file mode 100644
index 0000000..aa525cb
--- /dev/null
+++ b/.idea/artifacts/AnalogClock.xml
@@ -0,0 +1,15 @@
+
+
+ $PROJECT_DIR$/out/artifacts/AnalogClock
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/artifacts/Automata.xml b/.idea/artifacts/Automata.xml
new file mode 100644
index 0000000..69403e5
--- /dev/null
+++ b/.idea/artifacts/Automata.xml
@@ -0,0 +1,22 @@
+
+
+ $PROJECT_DIR$/out/artifacts/Automata
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
new file mode 100644
index 0000000..b39b930
--- /dev/null
+++ b/.idea/compiler.xml
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/description.html b/.idea/description.html
new file mode 100644
index 0000000..cc10d56
--- /dev/null
+++ b/.idea/description.html
@@ -0,0 +1,2 @@
+Simple JavaFX 2.0 application that includes simple .fxml file with attached controller and Main class to quick start. Artifact to build JavaFX application is provided.
+
\ No newline at end of file
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
new file mode 100644
index 0000000..97626ba
--- /dev/null
+++ b/.idea/encodings.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/gradle.xml b/.idea/gradle.xml
new file mode 100644
index 0000000..3e3960b
--- /dev/null
+++ b/.idea/gradle.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__commons_io_commons_io_2_6.xml b/.idea/libraries/Maven__commons_io_commons_io_2_6.xml
new file mode 100644
index 0000000..d722698
--- /dev/null
+++ b/.idea/libraries/Maven__commons_io_commons_io_2_6.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_apiguardian_apiguardian_api_1_1_0.xml b/.idea/libraries/Maven__org_apiguardian_apiguardian_api_1_1_0.xml
new file mode 100644
index 0000000..f854ab0
--- /dev/null
+++ b/.idea/libraries/Maven__org_apiguardian_apiguardian_api_1_1_0.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_json_json_20190722.xml b/.idea/libraries/Maven__org_json_json_20190722.xml
new file mode 100644
index 0000000..0f42bad
--- /dev/null
+++ b/.idea/libraries/Maven__org_json_json_20190722.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_junit_jupiter_junit_jupiter_api_5_6_2.xml b/.idea/libraries/Maven__org_junit_jupiter_junit_jupiter_api_5_6_2.xml
new file mode 100644
index 0000000..ef160d2
--- /dev/null
+++ b/.idea/libraries/Maven__org_junit_jupiter_junit_jupiter_api_5_6_2.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_junit_platform_junit_platform_commons_1_6_2.xml b/.idea/libraries/Maven__org_junit_platform_junit_platform_commons_1_6_2.xml
new file mode 100644
index 0000000..f2699b9
--- /dev/null
+++ b/.idea/libraries/Maven__org_junit_platform_junit_platform_commons_1_6_2.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_opentest4j_opentest4j_1_2_0.xml b/.idea/libraries/Maven__org_opentest4j_opentest4j_1_2_0.xml
new file mode 100644
index 0000000..fbc1b16
--- /dev/null
+++ b/.idea/libraries/Maven__org_opentest4j_opentest4j_1_2_0.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..62f90ed
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..96b462c
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml
new file mode 100644
index 0000000..3b00020
--- /dev/null
+++ b/.idea/uiDesigner.xml
@@ -0,0 +1,125 @@
+
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+
+
+
+
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..94a25f7
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index dff5f3a..0000000
--- a/.travis.yml
+++ /dev/null
@@ -1 +0,0 @@
-language: java
diff --git a/Java-lab-5.iml b/Java-lab-5.iml
new file mode 100644
index 0000000..2ab6e04
--- /dev/null
+++ b/Java-lab-5.iml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/META-INF/MANIFEST.MF b/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..16328cc
--- /dev/null
+++ b/META-INF/MANIFEST.MF
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Main-Class: analogClock.Clock
+
diff --git a/META-INF2/META-INF/MANIFEST.MF b/META-INF2/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..440fa71
--- /dev/null
+++ b/META-INF2/META-INF/MANIFEST.MF
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Main-Class: sample.Main
+
diff --git a/out/artifacts/AnalogClock/Java-lab-5.jar b/out/artifacts/AnalogClock/Java-lab-5.jar
new file mode 100644
index 0000000..9884cb6
Binary files /dev/null and b/out/artifacts/AnalogClock/Java-lab-5.jar differ
diff --git a/out/artifacts/Automata/Automata.jar b/out/artifacts/Automata/Automata.jar
new file mode 100644
index 0000000..243f6a7
Binary files /dev/null and b/out/artifacts/Automata/Automata.jar differ
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..00364d0
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,49 @@
+
+
+ 4.0.0
+
+ Lab2
+ task2
+ 1.0-SNAPSHOT
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+
+ 8
+ 8
+
+
+
+
+
+
+
+ commons-io
+ commons-io
+ 2.6
+
+
+
+ org.junit.jupiter
+ junit-jupiter-api
+ 5.6.2
+ test
+
+
+
+ org.json
+ json
+ 20190722
+
+
+ org.junit.jupiter
+ junit-jupiter-api
+ 5.6.2
+ compile
+
+
+
\ No newline at end of file
diff --git a/src/main/java/analogClock/Clock.java b/src/main/java/analogClock/Clock.java
new file mode 100644
index 0000000..caea03f
--- /dev/null
+++ b/src/main/java/analogClock/Clock.java
@@ -0,0 +1,112 @@
+package analogClock;
+
+import javafx.animation.*;
+import javafx.application.Application;
+import javafx.scene.Group;
+import javafx.scene.Scene;
+import javafx.scene.image.ImageView;
+import javafx.scene.image.Image;
+import javafx.scene.paint.Color;
+import javafx.scene.shape.Circle;
+import javafx.scene.shape.Line;
+import javafx.scene.transform.Rotate;
+import javafx.stage.Stage;
+import java.util.Calendar;
+import java.util.GregorianCalendar;
+import javafx.util.Duration;
+
+import java.net.*;
+
+public class Clock extends Application {
+
+ @Override
+ public void start(Stage stage) throws Exception {
+ stage.setTitle("Analog analogClock.Clock");
+ Image image = new Image("WH2.jpg", 650, 650, false, false);
+ ImageView backGround = new ImageView(image);
+
+ Circle circle = new Circle();
+ circle.setCenterX(333.9);
+ circle.setCenterY(333.9);
+ circle.setRadius(7.5);
+ circle.setStrokeWidth(1.5);
+ circle.setStroke(Color.DARKORCHID);
+
+ //Set time
+ Calendar calendar = new GregorianCalendar();
+ double SecDegree = calendar.get(Calendar.SECOND) * (360 / 60);
+ double MinDegree = (calendar.get(Calendar.MINUTE) + SecDegree / 360) * (360 / 60);
+ double HrDegree = (calendar.get(Calendar.HOUR) + MinDegree / 360) * (360 / 12);
+
+ //Create hour clockwise
+ Line clockwiseHr = new Line(0, 0, 0, -157);
+ clockwiseHr.setStroke(Color.DARKVIOLET);
+ clockwiseHr.setStrokeWidth(4);
+ clockwiseHr.smoothProperty();
+ clockwiseHr.getStrokeLineJoin();
+ clockwiseHr.setTranslateX(333.9);
+ clockwiseHr.setTranslateY(333.9);
+
+ //Create second clockwise
+ Line clockwiseMin = new Line(0, 0, 0, -217);
+ clockwiseMin.setStroke(Color.DARKORCHID);
+ clockwiseMin.setStrokeWidth(3);
+ clockwiseMin.smoothProperty();
+ clockwiseMin.getStrokeLineJoin();
+ clockwiseMin.setTranslateX(333.9);
+ clockwiseMin.setTranslateY(333.9);
+
+ //Create second clockwise
+ Line clockwiseSec = new Line(0, 0, -0, -287);
+ clockwiseSec.setStroke(Color.DARKORCHID);
+ clockwiseSec.setStrokeWidth(2);
+ clockwiseSec.smoothProperty();
+ clockwiseSec.getStrokeLineJoin();
+ clockwiseSec.setTranslateX(333.9);
+ clockwiseSec.setTranslateY(333.9);
+
+ //Create the order of rotation
+ Rotate rotateHr = new Rotate();
+ rotateHr.setAngle(HrDegree);
+ rotateHr.setPivotX(0);
+ rotateHr.setPivotY(0);
+ clockwiseHr.getTransforms().addAll(rotateHr);
+
+ Rotate rotateMin = new Rotate(MinDegree);
+ rotateMin.setAngle(MinDegree);
+ rotateMin.setPivotX(0);
+ rotateMin.setPivotY(0);
+ clockwiseMin.getTransforms().addAll(rotateMin);
+
+ Rotate rotateSec = new Rotate(SecDegree);
+ rotateSec.setAngle(SecDegree);
+ rotateSec.setPivotX(0);
+ rotateSec.setPivotY(0);
+ clockwiseSec.getTransforms().addAll(rotateSec);
+
+ Timeline timelineH = new Timeline(new KeyFrame(Duration.hours(12),
+ new KeyValue(rotateHr.angleProperty(), 325 + HrDegree, Interpolator.LINEAR)));
+ Timeline timelineM = new Timeline(new KeyFrame(Duration.minutes(60),
+ new KeyValue(rotateSec.angleProperty(), 325 + MinDegree, Interpolator.LINEAR)));
+ Timeline timelineS = new Timeline(new KeyFrame(Duration.seconds(60),
+ new KeyValue(rotateSec.angleProperty(), 325 + SecDegree, Interpolator.LINEAR)));
+
+
+ timelineH.setCycleCount(Animation.INDEFINITE);
+ timelineM.setCycleCount(Animation.INDEFINITE);
+ timelineS.setCycleCount(Animation.INDEFINITE);
+
+ timelineH.play();
+ timelineM.play();
+ timelineS.play();
+
+ Group root = new Group(backGround, clockwiseHr, clockwiseMin, clockwiseSec, circle);
+ Scene scene = new Scene(root, 650, 650);
+ stage.setScene(scene);
+ stage.show();
+ }
+
+ public static void main(String[] args) {
+ launch(args);
+ }
+ }
diff --git a/src/main/java/automata/Automata.java b/src/main/java/automata/Automata.java
new file mode 100644
index 0000000..88265f9
--- /dev/null
+++ b/src/main/java/automata/Automata.java
@@ -0,0 +1,142 @@
+package automata;
+
+import org.apache.commons.io.FileUtils;
+import org.json.JSONObject;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+public class Automata {
+ public static enum STATES {
+ ON, OFF, WAIT, ACCEPT, CHECK, COOK
+ }
+ private int cash;
+ private JSONObject menu;
+ private int price;
+ private STATES state;
+
+ public Automata(){
+ cash = 0;
+ state = STATES.ON;
+ }
+
+ public void readMenu() {
+ try {
+ File file = resourcesTofile();
+ String stringOfMenu = FileUtils.readFileToString(file, "utf-8");
+ menu = new JSONObject(stringOfMenu);
+ System.out.println(menu.toString(4));
+ } catch (Exception ex) {
+ System.out.println(ex.getMessage());
+ }
+ }
+
+ private File resourcesTofile() {
+ try {
+ InputStream inputStream = ClassLoader.getSystemClassLoader().getResourceAsStream("DrinksAndPrices.json");
+ File temporaryFile = File.createTempFile("Temporary", ".tmp");
+ temporaryFile.deleteOnExit();
+ try (FileOutputStream outStream = new FileOutputStream(temporaryFile)) {
+ byte[] buffer = new byte[1024];
+ int bytesRead;
+ while ((bytesRead = inputStream.read(buffer)) != -1) {
+ outStream.write(buffer, 0, bytesRead);
+ }
+ }
+ return temporaryFile;
+ } catch (IOException e) {
+ e.printStackTrace();
+ return null;
+ }
+ }
+
+ public ArrayList getDrinks(){
+ ArrayList drinks = new ArrayList();
+ Iterator menu_iterator = menu.keys();
+ while (menu_iterator.hasNext()){
+ drinks.add(menu_iterator.next());
+ }
+ return drinks;
+ }
+
+ public STATES on() {
+ if (state == STATES.OFF) {
+ state = STATES.WAIT;
+ }
+ return state;
+ }
+ public STATES off() {
+ if (state == STATES.WAIT) {
+ state = STATES.OFF;
+ }
+ return state;
+ }
+
+ public int coin(int buyersCoin) {
+ if (state == STATES.WAIT) {
+ state = STATES.ACCEPT;
+ }
+ if (state == STATES.ACCEPT && buyersCoin > 0) {
+ cash = cash + buyersCoin;
+ } else {
+ cancel();
+ }
+ return cash;
+ }
+
+ public int choice(String drinkName) {
+ price = menu.getInt(drinkName);
+ state = STATES.CHECK;
+ System.out.println("The price of your " + drinkName + " is: " + price + " rubles");
+ return price;
+ }
+
+ public int check() {
+ int change = 0;
+ if (price <= cash && state == STATES.CHECK) {
+ change = cash - price;
+ System.out.println("Your have paid " + cash + " rubles. Take your change, please: " + change + " rubles");
+ return change;
+ }
+ if (price >= cash && state == STATES.CHECK) {
+ cancel();
+ }
+ //System.out.println("Your have paid " + cash + " rubles");
+ return cash;
+ }
+
+ public STATES getState() {
+ return state;
+ }
+
+ public void setState(STATES state) {
+ this.state = state;
+ }
+
+ public STATES cancel() {
+ if (price >= cash && state == STATES.CHECK) {
+ state = STATES.WAIT;
+ System.out.println("Sorry, this amount isn`t enought, take your coins back: " + cash + " rubles");
+ }
+ return state;
+ }
+
+ public void cook() {
+ if (state == STATES.CHECK) {
+ state = STATES.COOK;
+ System.out.println("Your drink is cooking, wait please...");
+ state = STATES.WAIT;
+ System.out.println("Take your drinks and enjoy it! I hope to see you again!");
+ }
+ finish();
+ }
+
+ public void finish() {
+ if (state == STATES.COOK && cash == 0) {
+ state = STATES.WAIT;
+ }
+ }
+}
diff --git a/src/main/java/automata/Main.java b/src/main/java/automata/Main.java
new file mode 100644
index 0000000..454a2cc
--- /dev/null
+++ b/src/main/java/automata/Main.java
@@ -0,0 +1,23 @@
+package automata;
+
+public class Main {
+ public static void main(String[] args) {
+ Automata auto = new Automata();
+ //This variable provides a random number of coin, which buyer have threw into the Automata
+ int buyersCoin = (int) (Math.random() *550);
+ //This variable provides a random number of drink, which buyer have chosen
+ int randomI = (int) (Math.random() * 10);
+ auto.setState(Automata.STATES.OFF);
+ System.out.println(auto.on());
+ auto.readMenu();
+ auto.coin(buyersCoin);
+ auto.getDrinks();
+ String randomDrink = auto.getDrinks().get(randomI);
+ auto.choice(randomDrink);
+ System.out.println("!!!" + auto.getState());
+ auto.check();
+ System.out.println(auto.getState());
+ auto.cook();
+ System.out.println(auto.getState());
+ }
+}
diff --git a/src/main/java/sample/Controller.java b/src/main/java/sample/Controller.java
new file mode 100644
index 0000000..f0696b8
--- /dev/null
+++ b/src/main/java/sample/Controller.java
@@ -0,0 +1,285 @@
+package sample;
+
+import automata.Automata;
+import javafx.concurrent.Task;
+import javafx.event.ActionEvent;
+import javafx.event.EventHandler;
+import javafx.fxml.FXML;
+import javafx.fxml.Initializable;
+import javafx.scene.control.Button;
+import javafx.scene.control.Label;
+import javafx.scene.control.TextField;
+import javafx.scene.image.ImageView;
+import javafx.scene.text.Text;
+
+import java.net.URL;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.ResourceBundle;
+import java.util.TimerTask;
+import java.util.Timer;
+
+public class Controller implements Initializable {
+ Automata auto = new Automata();
+
+ @FXML
+ private Button espresso;
+ @FXML
+ private Button espressoLarge;
+ @FXML
+ private Button americano;
+ @FXML
+ private Button americanoBig;
+ @FXML
+ private Button cappuccino;
+ @FXML
+ private Button cappuccinoLarge;
+ @FXML
+ private TextField actualState;
+ @FXML
+ private TextField buyersCoin;
+ @FXML
+ private TextField message;
+ @FXML
+ private Button putMoney;
+ @FXML
+ private Button cancel;
+ @FXML
+ private Button buy;
+ @FXML
+ private Button on;
+ @FXML
+ private Button off;
+ @FXML
+ private Button latte;
+ @FXML
+ private Button latteLarge;
+ @FXML
+ private Button hotChocolate;
+ @FXML
+ private Button hotChocolateBig;
+ @FXML
+ private Button blackTeaStandard;
+ @FXML
+ private Button greenTeaStandard;
+ @FXML
+ private ImageView picture;
+ private String drink;
+ private String cash;
+ private int price;
+ private int coins;
+ private int change;
+ private HashMap state = new HashMap<>();
+
+ {
+ state.put(Automata.STATES.ON, "ON");
+ state.put(Automata.STATES.OFF, "OFF");
+ state.put(Automata.STATES.WAIT, "WAIT");
+ state.put(Automata.STATES.ACCEPT, "ACCEPT");
+ state.put(Automata.STATES.CHECK, "CHECK");
+ state.put(Automata.STATES.COOK, "COOK");
+ }
+
+ @Override
+ public void initialize(URL location, ResourceBundle resources) {
+ System.out.println("Controller initialize");
+ }
+
+ @FXML
+ public void clickOn() {
+ auto.on();
+ actualState.setText(state.get(auto.getState()));
+ message.setText("Hello! Please, put your money and press \"Put money!\"");
+ }
+
+ @FXML
+ public void clickOff() {
+ auto.off();
+ actualState.setText(state.get(auto.getState()));
+ message.clear();
+ }
+
+ @FXML
+ public void clickCancel() {
+ auto.cancel();
+ message.setText("Please, take your " + cash + " rubles back!");
+ actualState.setText(state.get(auto.getState()));
+ buyersCoin.clear();
+ coins = 0;
+ }
+
+ @FXML
+ public void clickPutMoney() {
+ cash = buyersCoin.getText();
+ coins = Integer.parseInt(cash);
+ auto.coin(coins);
+ message.setText("You have put " + cash + " rubles. Please, choose your drink and press Buy!");
+ }
+
+ @FXML
+ public void clickEspresso() {
+ auto.readMenu();
+ drink = espresso.getText();
+ price = auto.choice(drink);
+ System.out.println(auto.getState());
+ actualState.setText(state.get(auto.getState()));
+ message.setText("The price of your drink is - " + price + " rubles. Please, press buy!");
+ }
+
+ @FXML
+ public void clickEspressoLarge() {
+ auto.readMenu();
+ drink = espressoLarge.getText();
+ price = auto.choice(drink);
+ actualState.setText(state.get(auto.getState()));
+ message.setText("The price of your drink is - " + price + " rubles. Please, press buy!");
+ }
+
+ @FXML
+ public void clickAmericano() {
+ auto.readMenu();
+ drink = americano.getText();
+ price = auto.choice(drink);
+ actualState.setText(state.get(auto.getState()));
+ message.setText("The price of your drink is - " + price + " rubles. Please, press buy!");
+ }
+
+ @FXML
+ public void clickAmericanoBig() {
+ auto.readMenu();
+ drink = americanoBig.getText();
+ price = auto.choice(drink);
+ actualState.setText(state.get(auto.getState()));
+ message.setText("The price of your drink is - " + price + " rubles. Please, press buy!");
+ }
+
+ @FXML
+ public void clickCappuccino() {
+ auto.readMenu();
+ drink = cappuccino.getText();
+ price = auto.choice(drink);
+ actualState.setText(state.get(auto.getState()));
+ message.setText("The price of your drink is - " + price + " rubles. Please, press buy!");
+ }
+
+ @FXML
+ public void clickCappuccinoLarge() {
+ auto.readMenu();
+ drink = cappuccinoLarge.getText();
+ price = auto.choice(drink);
+ actualState.setText(state.get(auto.getState()));
+ message.setText("The price of your drink is - " + price + " rubles. Please, press buy!");
+ }
+
+ @FXML
+ public void clickLatte() {
+ auto.readMenu();
+ drink = latte.getText();
+ price = auto.choice(drink);
+ actualState.setText(state.get(auto.getState()));
+ message.setText("The price of your drink is - " + price + " rubles. Please, press buy!");
+ }
+
+ @FXML
+ public void clickLatteLarge() {
+ auto.readMenu();
+ drink = latteLarge.getText();
+ price = auto.choice(drink);
+ actualState.setText(state.get(auto.getState()));
+ message.setText("The price of your drink is - " + price + " rubles. Please, press buy!");
+ }
+
+ @FXML
+ public void clickHotChocolate() {
+ auto.readMenu();
+ drink = hotChocolate.getText();
+ price = auto.choice(drink);
+ actualState.setText(state.get(auto.getState()));
+ message.setText("The price of your drink is - " + price + " rubles. Please, press buy!");
+ }
+
+ @FXML
+ public void clickHotChocolateBig() {
+ auto.readMenu();
+ drink = hotChocolateBig.getText();
+ price = auto.choice(drink);
+ actualState.setText(state.get(auto.getState()));
+ message.setText("The price of your drink is - " + price + " rubles. Please, press buy!");
+ }
+
+ @FXML
+ public void clickBlackTeaStandard() {
+ auto.readMenu();
+ drink = blackTeaStandard.getText();
+ price = auto.choice(drink);
+ actualState.setText(state.get(auto.getState()));
+ message.setText("The price of your drink is - " + price + " rubles. Please, press buy!");
+ }
+
+ @FXML
+ public void clickGreenTeaStandard() {
+ auto.readMenu();
+ drink = greenTeaStandard.getText();
+ price = auto.choice(drink);
+ actualState.setText(state.get(auto.getState()));
+ message.setText("The price of your drink is - " + price + " rubles. Please, press buy!");
+ }
+
+ @FXML
+ public void clickBuy() {
+ if ((state.get(auto.getState())).equals("CHECK")) {
+ Timer t1 = new Timer();
+ t1.schedule(new AutoTimerTask() {
+ @Override
+ public void run() {
+ System.out.println("AutoTimertask started" + new Date());
+ try {
+ if (price <= coins) {
+ change = coins - price;
+ if (change > 0) {
+ message.setText("Please, take your change " + change + " rubles.");
+ }
+ auto.check();
+ Thread.sleep(5000);
+ message.setText("Your drink is cooking, wait please...");
+ auto.cook();
+ actualState.setText(state.get(auto.getState()));
+ Thread.sleep(5000);
+ message.setText("Please, take your " + drink + " and enjoy it! I hope to see you again!");
+ } else {
+ auto.check();
+ message.setText("Sorry, this amount isn`t enought, take your coins back: " + coins + " rubles");
+ }
+ Thread.sleep(7000);
+ buyersCoin.clear();
+ message.clear();
+ coins = 0;
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ }, 500);
+ actualState.setText(state.get(auto.getState()));
+ }
+ }
+
+ class AutoTimerTask extends TimerTask {
+ @Override
+ public void run() {
+ System.out.println("AutoTimerTask started" + new Date());
+ completeTask();
+ System.out.println("AutoTimerTask finished" + new Date());
+
+ }
+
+ private void completeTask() {
+ try {
+ Thread.sleep(5000);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+
+
diff --git a/src/main/java/sample/Design-Your-Own-Biodegradable-8-Oz-Custom.jpg b/src/main/java/sample/Design-Your-Own-Biodegradable-8-Oz-Custom.jpg
new file mode 100644
index 0000000..0c011f2
Binary files /dev/null and b/src/main/java/sample/Design-Your-Own-Biodegradable-8-Oz-Custom.jpg differ
diff --git a/src/main/java/sample/Main.java b/src/main/java/sample/Main.java
new file mode 100644
index 0000000..fa4433a
--- /dev/null
+++ b/src/main/java/sample/Main.java
@@ -0,0 +1,25 @@
+package sample;
+
+
+import javafx.application.Application;
+import javafx.fxml.FXMLLoader;
+import javafx.scene.Parent;
+import javafx.scene.Scene;
+import javafx.stage.Stage;
+
+public class Main extends Application {
+
+ @Override
+ public void start(Stage primaryStage) throws Exception{
+ Parent root = FXMLLoader.load(getClass().getResource("/sample.fxml"));
+ primaryStage.setTitle("AUTOMATA");
+ primaryStage.setScene(new Scene(root, 590, 650));
+ primaryStage.show();
+
+ }
+
+
+ public static void main(String[] args) {
+ launch(args);
+ }
+}
diff --git a/src/main/resources/Design-Your-Own-Biodegradable-8-Oz-Custom.jpg b/src/main/resources/Design-Your-Own-Biodegradable-8-Oz-Custom.jpg
new file mode 100644
index 0000000..0c011f2
Binary files /dev/null and b/src/main/resources/Design-Your-Own-Biodegradable-8-Oz-Custom.jpg differ
diff --git a/src/main/resources/DrinksAndPrices.json b/src/main/resources/DrinksAndPrices.json
new file mode 100644
index 0000000..6de5d50
--- /dev/null
+++ b/src/main/resources/DrinksAndPrices.json
@@ -0,0 +1,14 @@
+{
+ "Espresso" : 60,
+ "Espresso large" : 100,
+ "Americano" : 70,
+ "Americano big" : 110,
+ "Cappuccino" : 80,
+ "Cappuccino large" : 140,
+ "Latte" : 85,
+ "Latte large" : 105,
+ "Hot chocolate" : 90,
+ "Hot chocolate big" : 160,
+ "Black tea standard" : 50,
+ "Green tea standard" : 55
+}
\ No newline at end of file
diff --git a/src/main/resources/WH2.jpg b/src/main/resources/WH2.jpg
new file mode 100644
index 0000000..c8aee89
Binary files /dev/null and b/src/main/resources/WH2.jpg differ
diff --git a/src/main/resources/sample.fxml b/src/main/resources/sample.fxml
new file mode 100644
index 0000000..fc190fa
--- /dev/null
+++ b/src/main/resources/sample.fxml
@@ -0,0 +1,201 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+