diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..eacdf1d --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/pointer-enum.iml +/.idea/ diff --git a/com/src/Main.java b/com/src/Main.java new file mode 100644 index 0000000..4d70286 --- /dev/null +++ b/com/src/Main.java @@ -0,0 +1,19 @@ +package src; + +import java.util.Scanner; + +public class Main { + + + public static void main(String[] args) { + Scanner str = new Scanner(System.in); + System.out.println(" Hello, you are in our fruit shop and we have: "); + Shop.giveFruits(); + System.out.println("Write your choice"); + String writeFruit = str.nextLine(); + str.close(); + Shop.showYourFruit(Shop.valueOf(writeFruit.toUpperCase())); + + + } +} diff --git a/com/src/Shop.java b/com/src/Shop.java new file mode 100644 index 0000000..61aadc8 --- /dev/null +++ b/com/src/Shop.java @@ -0,0 +1,42 @@ +package src; + +public enum Shop { + CHERRY("CHERRY", 50, 5), + ORANGE("ORANGE", 40, 6), + STRAWBERRY("STRAWBERRY", 30, 7), + LEMON("LEMON", 20, 8), + PEAR("PEAR", 10, 9); + private String fruits; + private int weight; + private int coast; + + Shop(String fruits, int weight, int coast) { + this.coast = coast; + this.fruits = fruits; + this.weight = weight; + } + + public String toString() { + return fruits; + } + + static void giveFruits() { + for (Shop fruits : Shop.values()) { + System.out.println(fruits.name()); + } + } + + static void showYourFruit(Shop fruits) { + switch (fruits) { + case PEAR: + case LEMON: + case CHERRY: + case ORANGE: + case STRAWBERRY: + System.out.println("You want" + fruits.toString() + " OUR SHOP can to give you some:" + fruits.weight + " kg" + " for " + fruits.coast + " grn/kg"); + break; + } + } + + +}