Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/pointer-enum.iml
/.idea/
19 changes: 19 additions & 0 deletions com/src/Main.java
Original file line number Diff line number Diff line change
@@ -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()));


}
}
42 changes: 42 additions & 0 deletions com/src/Shop.java
Original file line number Diff line number Diff line change
@@ -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;
}
}


}