diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..ab1f416 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,10 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Ignored default folder with query files +/queries/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..39f2aec --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..044d158 --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml new file mode 100644 index 0000000..712ab9d --- /dev/null +++ b/.idea/jarRepositories.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/lab-java-maven.iml b/.idea/lab-java-maven.iml new file mode 100644 index 0000000..d6ebd48 --- /dev/null +++ b/.idea/lab-java-maven.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..3a64983 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,14 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..99bd203 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/solution-lab-2.02-maven/order-data/pom.xml b/solution-lab-2.02-maven/order-data/pom.xml new file mode 100644 index 0000000..7f3d4fa --- /dev/null +++ b/solution-lab-2.02-maven/order-data/pom.xml @@ -0,0 +1,23 @@ + + + 4.0.0 + + org.example + solution-lab-2.02-maven + 1.0-SNAPSHOT + + + order-data + + + 25 + 25 + UTF-8 + + + + + + \ No newline at end of file diff --git a/solution-lab-2.02-maven/order-data/src/main/java/org/example/Customer.java b/solution-lab-2.02-maven/order-data/src/main/java/org/example/Customer.java new file mode 100644 index 0000000..95c6278 --- /dev/null +++ b/solution-lab-2.02-maven/order-data/src/main/java/org/example/Customer.java @@ -0,0 +1,35 @@ +package org.example; + +public class Customer { + private String name; + private String email; + + public Customer(String name, String email) { + this.name = name; + this.email = email; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + @Override + public String toString() { + return "{" + + "\nname: " + name + + ",\nemail: " + email + + ",\n}"; + } +} diff --git a/solution-lab-2.02-maven/order-data/src/main/java/org/example/Order.java b/solution-lab-2.02-maven/order-data/src/main/java/org/example/Order.java new file mode 100644 index 0000000..cbfa182 --- /dev/null +++ b/solution-lab-2.02-maven/order-data/src/main/java/org/example/Order.java @@ -0,0 +1,65 @@ +package org.example; + +import com.google.gson.annotations.SerializedName; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + +public class Order { + @SerializedName("order_id") + private UUID id; + private Customer customer; + private List items=new ArrayList<>(); + private BigDecimal total; + + public Order(UUID id, Customer customer, List items, BigDecimal total) { + this.id = id; + this.customer = customer; + this.items = items; + this.total = total; + } + + public UUID getId() { + return id; + } + + public void setId(UUID id) { + this.id = id; + } + + public Customer getCustomer() { + return customer; + } + + public void setCustomer(Customer customer) { + this.customer = customer; + } + + public List getItems() { + return items; + } + + public void setItems(List items) { + this.items = items; + } + + public BigDecimal getTotal() { + return total; + } + + public void setTotal(BigDecimal total) { + this.total = total; + } + + @Override + public String toString() { + return "{" + + "\norder_id: " + id + + ",\ncustomer: "+customer.toString() + + ",\nitems: " + items.toString() + + ",\ntotal :" + total + + "\n}"; + } +} diff --git a/solution-lab-2.02-maven/order-data/src/main/java/org/example/OrderItem.java b/solution-lab-2.02-maven/order-data/src/main/java/org/example/OrderItem.java new file mode 100644 index 0000000..ef1a003 --- /dev/null +++ b/solution-lab-2.02-maven/order-data/src/main/java/org/example/OrderItem.java @@ -0,0 +1,63 @@ +package org.example; + +import com.google.gson.annotations.SerializedName; + +import java.util.UUID; + +public class OrderItem { + @SerializedName("product_id") + private UUID id; + @SerializedName("product_name") + private String name; + private int quantity; + private double price; + + public OrderItem(UUID id, String name, int quantity, double price) { + this.id = id; + this.name = name; + this.quantity = quantity; + this.price = price; + } + + public UUID getId() { + return id; + } + + public void setId(UUID id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getQuantity() { + return quantity; + } + + public void setQuantity(int quantity) { + this.quantity = quantity; + } + + public double getPrice() { + return price; + } + + public void setPrice(double price) { + this.price = price; + } + + @Override + public String toString() { + return "{" + + "\nproduct_id: " + id + + ",\nproduct_name: '" + name + '\'' + + ",\nquantity: " + quantity + + ",\nprice: " + price + + '}'; + } +} diff --git a/solution-lab-2.02-maven/order-data/src/main/java/org/example/OrderProcessor.java b/solution-lab-2.02-maven/order-data/src/main/java/org/example/OrderProcessor.java new file mode 100644 index 0000000..755af2d --- /dev/null +++ b/solution-lab-2.02-maven/order-data/src/main/java/org/example/OrderProcessor.java @@ -0,0 +1,18 @@ +package org.example; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; + +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.util.ArrayList; +import java.util.List; + +public class OrderProcessor { + static void main() throws FileNotFoundException { + FileReader reader= new FileReader("C:\\Users\\Administrator\\IdeaProjects\\lab-java-maven\\solution-lab-2.02-maven\\order-data\\src\\main\\java\\org\\example\\order.json"); + Gson gson=new Gson(); + Order order=gson.fromJson(reader, Order.class); + System.out.println(order.toString()); + } +} diff --git a/solution-lab-2.02-maven/order-data/src/main/java/org/example/order.json b/solution-lab-2.02-maven/order-data/src/main/java/org/example/order.json new file mode 100644 index 0000000..50214e4 --- /dev/null +++ b/solution-lab-2.02-maven/order-data/src/main/java/org/example/order.json @@ -0,0 +1,22 @@ +{ + "order_id": "550e8400-e29b-41d4-a716-446655440000", + "customer": { + "name": "Alice Johnson", + "email": "alice@example.com" + }, + "items": [ + { + "product_id": "123e4567-e89b-12d3-a456-426614174000", + "product_name": "Wireless Mouse", + "quantity": 2, + "price": 25.00 + }, + { + "product_id": "987e6543-e21b-12d3-a456-426614174111", + "product_name": "Keyboard", + "quantity": 1, + "price": 50.0 + } + ], + "total": 100.0 +} diff --git a/solution-lab-2.02-maven/order-data/target/classes/org/example/Customer.class b/solution-lab-2.02-maven/order-data/target/classes/org/example/Customer.class new file mode 100644 index 0000000..9358df1 Binary files /dev/null and b/solution-lab-2.02-maven/order-data/target/classes/org/example/Customer.class differ diff --git a/solution-lab-2.02-maven/order-data/target/classes/org/example/Order.class b/solution-lab-2.02-maven/order-data/target/classes/org/example/Order.class new file mode 100644 index 0000000..2e6f836 Binary files /dev/null and b/solution-lab-2.02-maven/order-data/target/classes/org/example/Order.class differ diff --git a/solution-lab-2.02-maven/order-data/target/classes/org/example/OrderItem.class b/solution-lab-2.02-maven/order-data/target/classes/org/example/OrderItem.class new file mode 100644 index 0000000..5d9320e Binary files /dev/null and b/solution-lab-2.02-maven/order-data/target/classes/org/example/OrderItem.class differ diff --git a/solution-lab-2.02-maven/order-data/target/classes/org/example/OrderProcessor.class b/solution-lab-2.02-maven/order-data/target/classes/org/example/OrderProcessor.class new file mode 100644 index 0000000..2ee65e3 Binary files /dev/null and b/solution-lab-2.02-maven/order-data/target/classes/org/example/OrderProcessor.class differ diff --git a/solution-lab-2.02-maven/order-data/target/maven-archiver/pom.properties b/solution-lab-2.02-maven/order-data/target/maven-archiver/pom.properties new file mode 100644 index 0000000..cf0abc0 --- /dev/null +++ b/solution-lab-2.02-maven/order-data/target/maven-archiver/pom.properties @@ -0,0 +1,3 @@ +artifactId=order-data +groupId=org.example +version=1.0-SNAPSHOT diff --git a/solution-lab-2.02-maven/order-data/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/solution-lab-2.02-maven/order-data/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst new file mode 100644 index 0000000..e3047c4 --- /dev/null +++ b/solution-lab-2.02-maven/order-data/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst @@ -0,0 +1,4 @@ +org\example\Customer.class +org\example\Order.class +org\example\OrderProcessor.class +org\example\OrderItem.class diff --git a/solution-lab-2.02-maven/order-data/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/solution-lab-2.02-maven/order-data/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst new file mode 100644 index 0000000..98c570b --- /dev/null +++ b/solution-lab-2.02-maven/order-data/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst @@ -0,0 +1,4 @@ +C:\Users\Administrator\IdeaProjects\lab-java-maven\solution-lab-2.02-maven\order-data\src\main\java\org\example\Customer.java +C:\Users\Administrator\IdeaProjects\lab-java-maven\solution-lab-2.02-maven\order-data\src\main\java\org\example\Order.java +C:\Users\Administrator\IdeaProjects\lab-java-maven\solution-lab-2.02-maven\order-data\src\main\java\org\example\OrderItem.java +C:\Users\Administrator\IdeaProjects\lab-java-maven\solution-lab-2.02-maven\order-data\src\main\java\org\example\OrderProcessor.java diff --git a/solution-lab-2.02-maven/order-data/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst b/solution-lab-2.02-maven/order-data/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst new file mode 100644 index 0000000..e69de29 diff --git a/solution-lab-2.02-maven/order-data/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst b/solution-lab-2.02-maven/order-data/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst new file mode 100644 index 0000000..e69de29 diff --git a/solution-lab-2.02-maven/order-data/target/order-data-1.0-SNAPSHOT.jar b/solution-lab-2.02-maven/order-data/target/order-data-1.0-SNAPSHOT.jar new file mode 100644 index 0000000..a5fa802 Binary files /dev/null and b/solution-lab-2.02-maven/order-data/target/order-data-1.0-SNAPSHOT.jar differ diff --git a/solution-lab-2.02-maven/order-logic/pom.xml b/solution-lab-2.02-maven/order-logic/pom.xml new file mode 100644 index 0000000..c8651a0 --- /dev/null +++ b/solution-lab-2.02-maven/order-logic/pom.xml @@ -0,0 +1,27 @@ + + + 4.0.0 + + org.example + solution-lab-2.02-maven + 1.0-SNAPSHOT + + + order-logic + + + 25 + 25 + UTF-8 + + + + org.example + order-data + 1.0-SNAPSHOT + + + + \ No newline at end of file diff --git a/solution-lab-2.02-maven/order-logic/src/main/java/org/example/OrderCalculator.java b/solution-lab-2.02-maven/order-logic/src/main/java/org/example/OrderCalculator.java new file mode 100644 index 0000000..b991435 --- /dev/null +++ b/solution-lab-2.02-maven/order-logic/src/main/java/org/example/OrderCalculator.java @@ -0,0 +1,30 @@ +package org.example; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + +public class OrderCalculator { + static void main() { + Gson gson = new GsonBuilder().setPrettyPrinting().create(); + Customer customer = new Customer("Mikayil", "miko@gmail.com"); + OrderItem item1 = new OrderItem(UUID.fromString("123e4567-e89b-12d3-a456-426614174000"), "USB", 2, 5.50); + OrderItem item2 = new OrderItem(UUID.fromString("125e4667-e89b-12d3-a456-426614174000"), "Printer", 1, 35.00); + List items = List.of(item1, item2); + BigDecimal total = calculateTotal(items); + Order order = new Order(UUID.fromString("e3e514f5-018f-4320-9b57-d602bd17a581"),customer, items, total); + System.out.println(gson.toJson(order)); + } + + public static BigDecimal calculateTotal(List items) { + BigDecimal sum = BigDecimal.valueOf(0); + for (OrderItem item : items) { + sum=sum.add(BigDecimal.valueOf(item.getQuantity()*item.getPrice())); + } + return sum; + } +} diff --git a/solution-lab-2.02-maven/order-logic/target/classes/org/example/OrderCalculator.class b/solution-lab-2.02-maven/order-logic/target/classes/org/example/OrderCalculator.class new file mode 100644 index 0000000..dc98831 Binary files /dev/null and b/solution-lab-2.02-maven/order-logic/target/classes/org/example/OrderCalculator.class differ diff --git a/solution-lab-2.02-maven/order-logic/target/maven-archiver/pom.properties b/solution-lab-2.02-maven/order-logic/target/maven-archiver/pom.properties new file mode 100644 index 0000000..2605634 --- /dev/null +++ b/solution-lab-2.02-maven/order-logic/target/maven-archiver/pom.properties @@ -0,0 +1,3 @@ +artifactId=order-logic +groupId=org.example +version=1.0-SNAPSHOT diff --git a/solution-lab-2.02-maven/order-logic/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/solution-lab-2.02-maven/order-logic/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst new file mode 100644 index 0000000..ea6bc7c --- /dev/null +++ b/solution-lab-2.02-maven/order-logic/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst @@ -0,0 +1 @@ +org\example\OrderCalculator.class diff --git a/solution-lab-2.02-maven/order-logic/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/solution-lab-2.02-maven/order-logic/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst new file mode 100644 index 0000000..45cb87a --- /dev/null +++ b/solution-lab-2.02-maven/order-logic/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst @@ -0,0 +1 @@ +C:\Users\Administrator\IdeaProjects\lab-java-maven\solution-lab-2.02-maven\order-logic\src\main\java\org\example\OrderCalculator.java diff --git a/solution-lab-2.02-maven/order-logic/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst b/solution-lab-2.02-maven/order-logic/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst new file mode 100644 index 0000000..e69de29 diff --git a/solution-lab-2.02-maven/order-logic/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst b/solution-lab-2.02-maven/order-logic/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst new file mode 100644 index 0000000..e69de29 diff --git a/solution-lab-2.02-maven/order-logic/target/order-logic-1.0-SNAPSHOT.jar b/solution-lab-2.02-maven/order-logic/target/order-logic-1.0-SNAPSHOT.jar new file mode 100644 index 0000000..82df766 Binary files /dev/null and b/solution-lab-2.02-maven/order-logic/target/order-logic-1.0-SNAPSHOT.jar differ diff --git a/solution-lab-2.02-maven/pom.xml b/solution-lab-2.02-maven/pom.xml new file mode 100644 index 0000000..939f514 --- /dev/null +++ b/solution-lab-2.02-maven/pom.xml @@ -0,0 +1,34 @@ + + + 4.0.0 + + org.example + solution-lab-2.02-maven + 1.0-SNAPSHOT + pom + + + 25 + 25 + UTF-8 + + + + org.slf4j + slf4j-api + 2.0.17 + compile + + + com.google.code.gson + gson + 2.11.0 + + + + order-data + order-logic + + \ No newline at end of file diff --git a/solution-lab-2.02-maven/src/main/java/org/example/Main.java b/solution-lab-2.02-maven/src/main/java/org/example/Main.java new file mode 100644 index 0000000..1bb4bf0 --- /dev/null +++ b/solution-lab-2.02-maven/src/main/java/org/example/Main.java @@ -0,0 +1,17 @@ +package org.example; + +//TIP To Run code, press or +// click the icon in the gutter. +public class Main { + static void main() { + //TIP Press with your caret at the highlighted text + // to see how IntelliJ IDEA suggests fixing it. + IO.println(String.format("Hello and welcome!")); + + for (int i = 1; i <= 5; i++) { + //TIP Press to start debugging your code. We have set one breakpoint + // for you, but you can always add more by pressing . + IO.println("i = " + i); + } + } +}