diff --git a/Automata/Automata.iml b/Automata/Automata.iml
new file mode 100644
index 0000000..c035f0b
--- /dev/null
+++ b/Automata/Automata.iml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Automata/out/artifacts/Automata_jar/Automata.jar b/Automata/out/artifacts/Automata_jar/Automata.jar
new file mode 100644
index 0000000..33819dc
Binary files /dev/null and b/Automata/out/artifacts/Automata_jar/Automata.jar differ
diff --git a/Automata/pom.xml b/Automata/pom.xml
new file mode 100644
index 0000000..eab3b48
--- /dev/null
+++ b/Automata/pom.xml
@@ -0,0 +1,28 @@
+
+
+ 4.0.0
+
+ org.example
+ Java-lab-5
+ 1.0-SNAPSHOT
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+
+ 1.8
+ 1.8
+
+
+
+
+
+ ${project.basedir}/src/main/resources
+
+
+
+
\ No newline at end of file
diff --git a/Automata/src/META-INF/MANIFEST.MF b/Automata/src/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..440fa71
--- /dev/null
+++ b/Automata/src/META-INF/MANIFEST.MF
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Main-Class: sample.Main
+
diff --git a/Automata/src/main/java/sample/Automata.java b/Automata/src/main/java/sample/Automata.java
new file mode 100644
index 0000000..7a441a6
--- /dev/null
+++ b/Automata/src/main/java/sample/Automata.java
@@ -0,0 +1,138 @@
+package sample;
+import java.util.ArrayList;
+
+public class Automata {
+ enum STATES {OFF, WAIT, ACCEPT, CHECK, COOK}
+ private int cash;
+ private int change;
+
+ public void setMenu() {
+ menu.add("Эспрессо 60 мл.");
+ menu.add("Американо");
+ menu.add("Кофе с молоком");
+ menu.add("Капучино");
+ menu.add("Латте");
+ menu.add("Двойной эспрессо");
+ menu.add("Мокачино");
+ menu.add("Шоколад");
+ menu.add("Двойной шоколад");
+ menu.add("Кофе с шоколадом");
+ menu.add("Шоколад с молоком");
+ menu.add("Капучино Амаретто");
+ }
+
+ public void setPrices() {
+ prices.add(25);
+ prices.add(25);
+ prices.add(25);
+ prices.add(30);
+ prices.add(30);
+ prices.add(40);
+ prices.add(35);
+ prices.add(25);
+ prices.add(30);
+ prices.add(25);
+ prices.add(30);
+ prices.add(30);
+ }
+
+ private ArrayList menu = new ArrayList<>();
+ private ArrayList prices = new ArrayList<>();
+ private STATES state;
+ private String message;
+ public Automata() {
+ cash = 0;
+ state = STATES.OFF;
+ }
+ public ArrayList getMenu(){
+ return menu;
+ }
+ public ArrayList getPrices(){
+ return prices;
+ }
+ public int getCash(){
+ return cash;
+ }
+ public int getChange(){
+ return change;
+ }
+ public STATES getState(){
+ return state;
+ }
+ public String getMessage() {
+ return message;
+ }
+ public void on(){
+ if(state.equals(STATES.OFF)){
+ message="Внесите деньги!";
+ state = STATES.WAIT;}
+ else
+ message="Некорректная операция!";
+ }
+ public void coin(int value){
+ if(state.equals(STATES.WAIT)){
+ change=0;
+ cash+=value;
+ state=STATES.ACCEPT;
+ message="Выберите напиток!";
+ }
+ else if(state.equals(STATES.ACCEPT)){
+ cash+=value;
+ }
+ else
+ message="Некорректная операция!";
+ }
+ public int choice(int numberOfButton){
+ int price=0;
+ if(state.equals(STATES.ACCEPT)){
+ price = prices.get(numberOfButton);
+ state = STATES.CHECK;
+ }
+ else
+ message="Некорректная операция!";
+ return price;
+ }
+ public boolean check(int price){
+ boolean check = false;
+ if(state.equals(STATES.CHECK)){
+ if (cash cbCash;
+ @FXML
+ private ProgressIndicator piProgress;
+ @FXML
+ private ImageView ivCup;
+
+ List menu;
+ List price;
+ Automata automata;
+
+ @Override
+ public void initialize(URL url, ResourceBundle resourceBundle) {
+ automata = new Automata();
+ automata.setMenu();
+ automata.setPrices();
+ menu = automata.getMenu();
+ price = automata.getPrices();
+ setComboBox();
+ setLblNames();
+ setlblPrices();
+ ivCup.setVisible(false);
+ }
+
+ public void setLblNames(){
+ String nameLeft1 = menu.get(0);
+ lblNameLeft1.setText(nameLeft1);
+ String nameLeft2 = menu.get(1);
+ lblNameLeft2.setText(nameLeft2);
+ String nameLeft3 = menu.get(2);
+ lblNameLeft3.setText(nameLeft3);
+ String nameLeft4 = menu.get(3);
+ lblNameLeft4.setText(nameLeft4);
+ String nameLeft5 = menu.get(4);
+ lblNameLeft5.setText(nameLeft5);
+ String nameLeft6 = menu.get(5);
+ lblNameLeft6.setText(nameLeft6);
+ String nameRight1 = menu.get(6);
+ lblNameRight1.setText(nameRight1);
+ String nameRight2 = menu.get(7);
+ lblNameRight2.setText(nameRight2);
+ String nameRight3 = menu.get(8);
+ lblNameRight3.setText(nameRight3);
+ String nameRight4 = menu.get(9);
+ lblNameRight4.setText(nameRight4);
+ String nameRight5 = menu.get(10);
+ lblNameRight5.setText(nameRight5);
+ String nameRight6 = menu.get(11);
+ lblNameRight6.setText(nameRight6);
+ }
+
+ public void setlblPrices(){
+ String priceLeft1 = price.get(0).toString();
+ lblPriceLeft1.setText(priceLeft1);
+ String priceLeft2 = price.get(1).toString();
+ lblPriceLeft2.setText(priceLeft2);
+ String priceLeft3 = price.get(2).toString();
+ lblPriceLeft3.setText(priceLeft3);
+ String priceLeft4 = price.get(3).toString();
+ lblPriceLeft4.setText(priceLeft4);
+ String priceLeft5 = price.get(4).toString();
+ lblPriceLeft5.setText(priceLeft5);
+ String priceLeft6 = price.get(5).toString();
+ lblPriceLeft6.setText(priceLeft6);
+ String priceRight1 = price.get(6).toString();
+ lblPriceRight1.setText(priceRight1);
+ String priceRight2 = price.get(7).toString();
+ lblPriceRight2.setText(priceRight2);
+ String priceRight3 = price.get(8).toString();
+ lblPriceRight3.setText(priceRight3);
+ String priceRight4 = price.get(9).toString();
+ lblPriceRight4.setText(priceRight4);
+ String priceRight5 = price.get(10).toString();
+ lblPriceRight5.setText(priceRight5);
+ String priceRight6 = price.get(11).toString();
+ lblPriceRight6.setText(priceRight6);
+ }
+
+ public void switchOn(){
+ automata.on();
+ lblMessage.setText(automata.getMessage());
+ }
+
+ public void switchOff(){
+ automata.off();
+ lblMessage.setText(automata.getMessage());
+ piProgress.setProgress(0);
+ }
+
+ public void setComboBox(){
+ ObservableList cashAvailable = FXCollections.observableArrayList(5,10,50,100);
+ cbCash.setItems(cashAvailable);
+ }
+
+ public void getCash(){
+ try {
+ int cash = cbCash.getValue();
+ automata.coin(cash);
+ lblMessage.setText(automata.getMessage());
+ }
+ catch (java.lang.NullPointerException e){};
+ }
+
+ public void btnLeft1Pressed(){
+ choiceAndCook(0);
+ }
+ public void btnLeft2Pressed(){
+ choiceAndCook(1);
+ }
+ public void btnLeft3Pressed(){
+ choiceAndCook(2);
+ }
+ public void btnLeft4Pressed(){
+ choiceAndCook(3);
+ }
+ public void btnLeft5Pressed(){
+ choiceAndCook(4);
+ }
+ public void btnLeft6Pressed(){
+ choiceAndCook(5);
+ }
+ public void btnRight1Pressed(){
+ choiceAndCook(6);
+ }
+ public void btnRight2Pressed(){
+ choiceAndCook(7);
+ }
+ public void btnRight3Pressed(){
+ choiceAndCook(8);
+ }
+ public void btnRight4Pressed(){
+ choiceAndCook(9);
+ }
+ public void btnRight5Pressed(){
+ choiceAndCook(10);
+ }
+ public void btnRight6Pressed() { choiceAndCook(11); }
+
+ public void choiceAndCook (int number) {
+ int price = automata.choice(number);
+ lblMessage.setText(automata.getMessage());
+ boolean check = automata.check(price);
+ if(check) {
+ Integer change = automata.getChange();
+ try {
+ cbCash.setValue(null);
+ }
+ catch (java.lang.NullPointerException e){};
+ lblChange.setText(change.toString());
+ new Thread(() -> {
+ cook(number, piProgress, lblMessage, ivCup);
+ }).start();
+ }
+ else
+ lblMessage.setText("недостаточно денег!");
+ }
+
+ public void cook(int number, ProgressIndicator piProgress, Label lblMessage, ImageView ivCup){
+ automata.cook();
+ try {
+ for(int i=0; i<=100; i++) {
+ Thread.sleep(50);
+ Double progress=(double)i/100;
+ Platform.runLater(() -> {
+ piProgress.setProgress(progress);
+ if (piProgress.getProgress()<1)
+ lblMessage.setText(menu.get(number) + " готовится");
+ else {
+ lblMessage.setText(menu.get(number) + " готов!");
+ ivCup.setVisible(true);
+ }
+ });
+ }
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ public void cancel(){
+ automata.cancel();
+ Integer change = automata.getChange();
+ lblChange.setText(change.toString());
+ try {
+ cbCash.setValue(null);
+ }
+ catch (java.lang.NullPointerException e){};
+ lblMessage.setText(automata.getMessage());
+ }
+}
diff --git a/Automata/src/main/java/sample/Main.java b/Automata/src/main/java/sample/Main.java
new file mode 100644
index 0000000..b6ef15b
--- /dev/null
+++ b/Automata/src/main/java/sample/Main.java
@@ -0,0 +1,23 @@
+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));
+ primaryStage.show();
+ }
+
+
+ public static void main(String[] args) {
+ launch(args);
+ }
+}
diff --git a/Automata/src/main/resources/Automata.jpg b/Automata/src/main/resources/Automata.jpg
new file mode 100644
index 0000000..234f2a9
Binary files /dev/null and b/Automata/src/main/resources/Automata.jpg differ
diff --git a/Automata/src/main/resources/cup.png b/Automata/src/main/resources/cup.png
new file mode 100644
index 0000000..f40cbea
Binary files /dev/null and b/Automata/src/main/resources/cup.png differ
diff --git a/Automata/src/main/resources/sample.fxml b/Automata/src/main/resources/sample.fxml
new file mode 100644
index 0000000..569c5ae
--- /dev/null
+++ b/Automata/src/main/resources/sample.fxml
@@ -0,0 +1,164 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Clock/Clock.iml b/Clock/Clock.iml
new file mode 100644
index 0000000..78b2cc5
--- /dev/null
+++ b/Clock/Clock.iml
@@ -0,0 +1,2 @@
+
+
\ No newline at end of file
diff --git a/Clock/out/artifacts/Clock_jar/Clock.jar b/Clock/out/artifacts/Clock_jar/Clock.jar
new file mode 100644
index 0000000..62b032c
Binary files /dev/null and b/Clock/out/artifacts/Clock_jar/Clock.jar differ
diff --git a/Clock/pom.xml b/Clock/pom.xml
new file mode 100644
index 0000000..d088a91
--- /dev/null
+++ b/Clock/pom.xml
@@ -0,0 +1,12 @@
+
+
+ 4.0.0
+
+ org.example
+ Clock
+ 1.0-SNAPSHOT
+
+
+
\ No newline at end of file
diff --git a/Clock/src/META-INF/MANIFEST.MF b/Clock/src/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..83187c5
--- /dev/null
+++ b/Clock/src/META-INF/MANIFEST.MF
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Main-Class: Clock
+
diff --git a/Clock/src/main/java/Clock.java b/Clock/src/main/java/Clock.java
new file mode 100644
index 0000000..4ae69a3
--- /dev/null
+++ b/Clock/src/main/java/Clock.java
@@ -0,0 +1,124 @@
+import javafx.animation.*;
+import javafx.application.Application;
+
+import javafx.scene.Group;
+import javafx.scene.Scene;
+import javafx.scene.image.Image;
+import javafx.scene.image.ImageView;
+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 javafx.util.Duration;
+import java.util.Calendar;
+import java.util.GregorianCalendar;
+
+import java.net.URL;
+
+
+
+public class Clock extends Application {
+ public static void main(String[] args) {
+ Application.launch(args);
+ }
+
+ @Override
+ public void start(Stage stage) {
+ stage.setTitle("Clock");
+ URL background = getClass().getResource("Clock.jpg");
+ Image im = new Image(background.toString(), 600, 600, false, false);
+ ImageView ivBack = new ImageView(im);
+
+ Calendar myCalendar = new GregorianCalendar();
+ double secDegree = myCalendar.get(Calendar.SECOND) * (360 / 60);
+ double minDegree = (myCalendar.get(Calendar.MINUTE) + secDegree / 360.0) * (360 / 60);
+ double hourDegree = (myCalendar.get(Calendar.HOUR) + minDegree / 360) * (360 / 12);
+
+ Line hour, min, sec;
+ hour = new Line(0, 0, 0, -150);
+ hour.setStroke(Color.BLACK);
+ hour.setStrokeWidth(10);
+ hour.setTranslateX(300);
+ hour.setTranslateY(330);
+ Rotate rotateHour = new Rotate();
+ rotateHour.setAngle(hourDegree);
+ rotateHour.setPivotX(0);
+ rotateHour.setPivotY(-30);
+ hour.getTransforms().addAll(rotateHour);
+
+ min = new Line(0, 0, -0, -180);
+ min.setStroke(Color.BLACK);
+ min.setStrokeWidth(5);
+ min.setTranslateX(300);
+ min.setTranslateY(330);
+ Rotate rotateMin = new Rotate();
+ rotateMin.setAngle(minDegree);
+ rotateMin.setPivotX(0);
+ rotateMin.setPivotY(-30);
+ min.getTransforms().addAll(rotateMin);
+
+ sec = new Line(0, 0, -0, -210);
+ sec.setStroke(Color.BLACK);
+ sec.setStrokeWidth(3);
+ sec.setTranslateX(300);
+ sec.setTranslateY(330);
+ Rotate rotateSec = new Rotate();
+ rotateSec.setAngle(secDegree);
+ rotateSec.setPivotX(0);
+ rotateSec.setPivotY(-30);
+ sec.getTransforms().addAll(rotateSec);
+
+ Circle circle = new Circle();
+ circle.setCenterX(300);
+ circle.setCenterY(300);
+ circle.setRadius(10);
+
+ final Timeline secTimeline = new Timeline(
+ new KeyFrame(
+ Duration.seconds(60),
+ new KeyValue(
+ rotateSec.angleProperty(),
+ 360 + secDegree,
+ Interpolator.LINEAR
+ )
+ )
+ );
+
+ final Timeline minTimeline = new Timeline(
+ new KeyFrame(
+ Duration.minutes(60),
+ new KeyValue(
+ rotateMin.angleProperty(),
+ 360 + minDegree,
+ Interpolator.LINEAR
+ )
+ )
+ );
+ final Timeline hourTimeline = new Timeline(
+ new KeyFrame(
+ Duration.hours(12),
+ new KeyValue(
+ rotateHour.angleProperty(),
+ 360 + hourDegree,
+ Interpolator.LINEAR
+ )
+ )
+ );
+ secTimeline.setCycleCount(Animation.INDEFINITE);
+ minTimeline.setCycleCount(Animation.INDEFINITE);
+ hourTimeline.setCycleCount(Animation.INDEFINITE);
+
+ secTimeline.play();
+ minTimeline.play();
+ hourTimeline.play();
+
+
+ Group root = new Group(ivBack, sec, min, hour, circle);
+ Scene scene = new Scene(root, 600, 600);
+ stage.setScene(scene);
+ stage.show();
+
+
+ }
+}
\ No newline at end of file
diff --git a/Clock/src/main/resources/Clock.jpg b/Clock/src/main/resources/Clock.jpg
new file mode 100644
index 0000000..e218308
Binary files /dev/null and b/Clock/src/main/resources/Clock.jpg differ