diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..39dabb3 --- /dev/null +++ b/.idea/encodings.xml @@ -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..56c7380 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,12 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml new file mode 100644 index 0000000..2b63946 --- /dev/null +++ b/.idea/uiDesigner.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ 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/iulia/pom.xml b/iulia/pom.xml new file mode 100644 index 0000000..500cb6d --- /dev/null +++ b/iulia/pom.xml @@ -0,0 +1,46 @@ + + + tutorial-java + com.imalittletester + 1.0-SNAPSHOT + + 4.0.0 + + iulia + jar + + iulia + http://maven.apache.org + + + + org.apache.maven.plugins + maven-compiler-plugin + + 14 + 14 + + + + + + + UTF-81.71.7 + + + + + + commons-io + commons-io + 2.11.0 + + + + org.apache.commons + commons-lang3 + 3.12.0 + + + diff --git a/iulia/src/main/java/com/imalittletester/garmincookies/CookieStructure.java b/iulia/src/main/java/com/imalittletester/garmincookies/CookieStructure.java new file mode 100644 index 0000000..d419656 --- /dev/null +++ b/iulia/src/main/java/com/imalittletester/garmincookies/CookieStructure.java @@ -0,0 +1,57 @@ +package com.imalittletester.garmincookies; + +import java.util.Date; + +public class CookieStructure { + + public String name; + public int size; + public long value; + public boolean httpOnly; + public char secure = '✓'; + public String priority; + public Date expirationDate; + private boolean isProvidedParamSubDomainOfDomain; + + public CookieStructure () { //constructor default + } + + public CookieStructure(String name, int size, long value, boolean httpOnly, char secure, String priority, Date expirationDate, boolean isProvidedParamSubDomainOfDomain) { + this.name = name; + this.size = size; + this.value = value; + this.httpOnly = httpOnly; + this.secure = secure; + this.priority = priority; + this.expirationDate = expirationDate; + this.isProvidedParamSubDomainOfDomain = isProvidedParamSubDomainOfDomain; + }//constructor with all fields + + + public CookieStructure(String name, long value) { + this.name = name; + this.value = value; //constructor name and value + } + + @Override + public String toString() { + return "CookieStructure{" + + "name='" + name + '\'' + + ", size=" + size + + ", value=" + value + + ", httpOnly=" + httpOnly + + ", secure=" + secure + + ", priority='" + priority + '\'' + + ", expirationDate=" + expirationDate + + ", isProvidedParamSubDomainOfDomain=" + isProvidedParamSubDomainOfDomain + + '}'; + } + + + public boolean isProvidedParamSubDomainOfDomain(String stringToCheck) { + return name.contains(stringToCheck) ; + } + + + } + diff --git a/iulia/src/main/java/com/imalittletester/homeworks/MonthHomework.java b/iulia/src/main/java/com/imalittletester/homeworks/MonthHomework.java new file mode 100644 index 0000000..b09d1a7 --- /dev/null +++ b/iulia/src/main/java/com/imalittletester/homeworks/MonthHomework.java @@ -0,0 +1,32 @@ +package com.imalittletester.homeworks; + +public class MonthHomework { + + public boolean checkIfLastDayOfMonth(String monthName, int dayNumber) { + boolean result; + + if (monthName.equals("April")|| monthName.equals("June")|| monthName.equals("September")|| monthName.equals("November")) { + result = dayNumber ==30; + return result; + } + if (monthName.equals("February")) { + result = dayNumber==28; + } + else { + result = dayNumber == 31; + } + return result; + } + public int countNumbersDivided(int maxLimit) { + int count = 0; + for (int i = 1; i <= maxLimit; i++) { + if (i % 7 == 0) + { + count++; + } + } + return count; + } + } + + diff --git a/iulia/src/main/java/com/imalittletester/homeworks/Watch.java b/iulia/src/main/java/com/imalittletester/homeworks/Watch.java new file mode 100644 index 0000000..e7628c9 --- /dev/null +++ b/iulia/src/main/java/com/imalittletester/homeworks/Watch.java @@ -0,0 +1,69 @@ +package com.imalittletester.homeworks; + +import java.sql.Timestamp; +import java.text.SimpleDateFormat; +import java.util.Date; + +public class Watch { + public String timeStamp; + public double stepsToday; + public double stepsThisWeek; + public float distanceToday; + public String distanceUom; + public int calories; + public Date currentTime; + public int idleAlerts; + public float distanceThisWeek; + public int hour; + private int anInt; + + public Watch(String timestamp, double stepsToday, double stepsThisWeek, String distanceUom, int calories, Date currentTime, int idleAlerts, int hour) { + this.timeStamp = timestamp; + this.stepsToday = stepsToday; + this.stepsThisWeek = stepsThisWeek; + this.distanceUom = distanceUom; + this.calories = calories; + this.currentTime = currentTime; + this.idleAlerts = idleAlerts; + this.hour = hour; + } + + public double unitConvertorForOneDay() { + double distanceToday = stepsToday; + if (distanceUom.equalsIgnoreCase("km")) { + return stepsToday / 1408; + } + if (distanceUom.equalsIgnoreCase("miles")) { + return stepsToday / 2000; + } + return distanceToday; + } + + public double unitConvertorForOneWeek() { + double distanceThisWeek = stepsThisWeek; + if (distanceUom.equalsIgnoreCase("km")) { + return stepsThisWeek / 1408; + } + if (distanceUom.equalsIgnoreCase("miles")) { + return stepsThisWeek / 2000; + } + return stepsThisWeek; + } + + public int idleAlerts() { + anInt = hour; + if (anInt >= 06) { + return idleAlerts; + } else { + return 0; + } + } + public void getWatchData() { + System.out.println("Number of steps until: " + timeStamp + " is: " + stepsToday); + System.out.println("Calories burned: " + calories); + System.out.println("Distance today: " + unitConvertorForOneDay() + " " + distanceUom); + System.out.println("Distance this week: " + unitConvertorForOneWeek()+" " + distanceUom); + System.out.println("Current date: " + currentTime); + System.out.println("Number of idle alerts: " + idleAlerts()); + } +} diff --git a/iulia/src/main/java/com/imalittletester/jam/ApricotJam.java b/iulia/src/main/java/com/imalittletester/jam/ApricotJam.java new file mode 100644 index 0000000..3f2ff2d --- /dev/null +++ b/iulia/src/main/java/com/imalittletester/jam/ApricotJam.java @@ -0,0 +1,5 @@ + + + + + diff --git a/iulia/src/main/java/com/imalittletester/jam/Bottle.java b/iulia/src/main/java/com/imalittletester/jam/Bottle.java new file mode 100644 index 0000000..0879fa8 --- /dev/null +++ b/iulia/src/main/java/com/imalittletester/jam/Bottle.java @@ -0,0 +1,12 @@ +package com.imalittletester.jam; + +public class Bottle { + + public int bottleQty; + public int bottleCapacity; + + public Bottle(int bottleQty, int bottleCapacity) { + this.bottleQty = bottleQty; + this.bottleCapacity = bottleCapacity; + } +} diff --git a/iulia/src/main/java/com/imalittletester/jam/Fruit.java b/iulia/src/main/java/com/imalittletester/jam/Fruit.java new file mode 100644 index 0000000..9f6bc02 --- /dev/null +++ b/iulia/src/main/java/com/imalittletester/jam/Fruit.java @@ -0,0 +1,17 @@ +package com.imalittletester.jam; + +import java.util.ArrayList; +import java.util.List; + +public class Fruit { + private String name; + private double qty; + private String uom; + + public Fruit(String name, double qty, String uom) { + this.name = name; + this.qty = qty; + this.uom = uom; + } + } + diff --git a/iulia/src/main/java/com/imalittletester/jam/Jam.java b/iulia/src/main/java/com/imalittletester/jam/Jam.java new file mode 100644 index 0000000..c8822d8 --- /dev/null +++ b/iulia/src/main/java/com/imalittletester/jam/Jam.java @@ -0,0 +1,103 @@ +package com.imalittletester.jam; + +import javax.xml.namespace.QName; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +public class Jam { + + public String sweetener; + public float sweetenerQty; + public String sweetenerUom; + public boolean isDietetic; + public Jar jar; + + List fruits = new ArrayList<>(); + + public Jam(String sweetener, float sweetenerQty, String sweetenerUom, boolean isDietetic, Jar jar) { + this.sweetener = sweetener; + this.sweetenerQty = sweetenerQty; + this.sweetenerUom = sweetenerUom; + this.isDietetic = isDietetic; + this.jar = jar; + } + + public Jam(String sweetener, float sweetenerQty, String sweetenerUom, boolean isDietetic, Jar jar, List fruits) { + this.sweetener = sweetener; + this.sweetenerQty = sweetenerQty; + this.sweetenerUom = sweetenerUom; + this.isDietetic = isDietetic; + this.jar = jar; + this.fruits = fruits; + } + + public Jam() { + } + public Jam(String sweetener) { + this.sweetener = sweetener; + } + public Jam(String sweetener, float sweetenerQty, String sweetenerUom) { + this.sweetener = sweetener; + this.sweetenerQty = sweetenerQty; + this.sweetenerUom = sweetenerUom; + this.isDietetic = isDietetic; + this.isDietetic = sweetener.equals("sucralose")|| sweetener.equals("stevia"); + } + + public void makeJam() { + System.out.println("Adding " + sweetenerQty + " " + sweetenerUom + " " + "of " + sweetener); + System.out.println("Is jam dietetic? " + isDietetic); + System.out.println(isDietetic ? "Is jam dietetic? Yes" : "Is jam dietetic? No"); + } + + public int howManyFullJars (int jamQtyInGrams) { + return jamQtyInGrams / jar.jarCapacity; + } + public int remainderJam (int jamQtyInGrams) { + return jamQtyInGrams % jar.jarCapacity; + } + + //ifs + public double qtyGramsUsingIf(String uom, double qty) { + double mustMultiplyBy = 1; + if (uom.equalsIgnoreCase( "kg")|| uom.equalsIgnoreCase("kilograms")) { + mustMultiplyBy = 1000; + } + if (uom.equalsIgnoreCase("micrograms")) { + mustMultiplyBy = 0.0001; + } + return qty * mustMultiplyBy; + } + + public double qtyInGramsUsingIfSimple (String uom, double qty) { + if (uom.equalsIgnoreCase("kg") || uom.equalsIgnoreCase("kilograms")) { + return qty * 1000; + } + if (uom.equalsIgnoreCase("micrograms")) { + return qty / 1000; + } + return qty; + } + + public double qtyInGramsUsingSwitch (String uom, double qty) { + double valueToReturn = 0; + switch (uom.toLowerCase()) { + case "kg", "kilograms" -> {valueToReturn = qty * 1000;} + case "grams" -> {valueToReturn = qty;} + case "micrograms" -> {valueToReturn = qty/100;} + } + return valueToReturn; + } + //simple switch + public double qtyInGramsUsingSwitchSimple (String uom, double qty) { + switch (uom.toLowerCase()) { + case "kg", "kilograms" -> {return qty * 1000;} + case "grams" -> {return qty;} + case "micrograms" -> {return qty/100;} + default -> {return 0;} + } + } +} + + diff --git a/iulia/src/main/java/com/imalittletester/jam/Jar.java b/iulia/src/main/java/com/imalittletester/jam/Jar.java new file mode 100644 index 0000000..0c1d412 --- /dev/null +++ b/iulia/src/main/java/com/imalittletester/jam/Jar.java @@ -0,0 +1,12 @@ +package com.imalittletester.jam; + +public class Jar { + public int jarCapacity; + public int jarQty; + + public Jar(int jarCapacity, int jarQty) { + this.jarCapacity = jarCapacity; + this.jarQty = jarQty; + } +} + diff --git a/iulia/src/main/java/com/imalittletester/jam/MelonJam.java b/iulia/src/main/java/com/imalittletester/jam/MelonJam.java new file mode 100644 index 0000000..e69de29 diff --git a/iulia/src/test/java/com/imalittletester/jam/CookieStructureTest.java b/iulia/src/test/java/com/imalittletester/jam/CookieStructureTest.java new file mode 100644 index 0000000..9aceb8c --- /dev/null +++ b/iulia/src/test/java/com/imalittletester/jam/CookieStructureTest.java @@ -0,0 +1,25 @@ +package com.imalittletester.jam; + +import com.imalittletester.garmincookies.CookieStructure; +import org.junit.jupiter.api.Test; + +import java.util.Date; + +public class CookieStructureTest { + + public CookieStructure cookieStructure = new CookieStructure(); + + public CookieStructure cookieStructure2 = new CookieStructure(); + + public CookieStructure cookieStructure3 = new CookieStructure("notice preferences",20,34343434343443L,true,'✓',"medium", new Date(),false); + + @Test + void firstTest(){ + System.out.println(cookieStructure); + System.out.println(cookieStructure2); + System.out.println(cookieStructure3); + System.out.println(cookieStructure3.isProvidedParamSubDomainOfDomain("preferences")); + } + + +} diff --git a/iulia/src/test/java/com/imalittletester/jam/JamTest.java b/iulia/src/test/java/com/imalittletester/jam/JamTest.java new file mode 100644 index 0000000..cfa0f17 --- /dev/null +++ b/iulia/src/test/java/com/imalittletester/jam/JamTest.java @@ -0,0 +1,87 @@ +package com.imalittletester.jam; + +import org.junit.jupiter.api.MethodOrderer; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestMethodOrder; + +import java.util.Date; +@TestMethodOrder(MethodOrderer.OrderAnnotation.class) +public class JamTest { + + public int aPositiveValue = 10; + public long aPositiveLong = -1001001; + public float aFloat = 500; + public double aDouble = 29292.29292929229; + public boolean aBoolean; + public String aSweetener = "sugar\ncane"; + public Date new_Date; + + public Jam apricotJam = new Jam(); + public Jam apricotJam2 = new Jam("stevia",1.5f,"kg",true,new Jar(50,400)); + public Jam apricotJam3 = new Jam("sugar cane",1,"kg",false,new Jar(800,40)); + public Jam melonJam = new Jam("plain sugar",2,"kg",false,new Jar(500,20)); + + + @Order(1) + @Test + void thirdTest() { + apricotJam3.makeJam(); + System.out.println("------------------"); + melonJam.makeJam(); + + System.out.println("avem " + apricotJam3.howManyFullJars(2300) + " borcane pline."); + System.out.println("mai raman " + apricotJam3.remainderJam(2300) + "g."); + System.out.println(apricotJam3.equals(apricotJam2)); + } + + @Test + void forthTest() { + apricotJam3.makeJam(); + System.out.println("Is jam made with stevia dietetic? " + apricotJam3.isDietetic); + System.out.println("Is jam made with sugar cane dietetic? " + apricotJam2.isDietetic); + } + + + @Order(2) + @Test + void secondTest() { + System.out.println("------------------"); + System.out.println(apricotJam); + System.out.println(apricotJam2); + System.out.println(apricotJam3); + apricotJam3.makeJam(); + apricotJam3.sweetener.contains("sugar"); + melonJam.makeJam(); + + } + + @Order(3) + @Test + void firstTest() { + // System.out.println(aPositiveValue); + // System.out.println(aPositiveLong); + // System.out.println(aFloat); + // System.out.println(aDouble); + // System.out.println(aBoolean); + //System.out.println(" -->" + aSweetener); + + System.out.println(apricotJam3.howManyFullJars(2300)); + System.out.println(apricotJam3.remainderJam(2300)); + System.out.println(apricotJam3.equals(apricotJam2)); + } + + @Test + void fifthTest() { + System.out.println(apricotJam3.qtyGramsUsingIf("kg", 2.5f)); + System.out.println(apricotJam3.qtyGramsUsingIf("micrograms", 1000)); + System.out.println(apricotJam3.qtyGramsUsingIf("grams", 125)); + + System.out.println("----------------------------------------------"); + System.out.println(apricotJam3.qtyInGramsUsingSwitchSimple("micrograme", 2500)); + System.out.println("------------------------------------------------"); + System.out.println(apricotJam3.qtyInGramsUsingSwitchSimple("grams", 78)); + + } +} + diff --git a/iulia/src/test/java/com/imalittletester/jam/MonthHomeworkTest.java b/iulia/src/test/java/com/imalittletester/jam/MonthHomeworkTest.java new file mode 100644 index 0000000..22cea05 --- /dev/null +++ b/iulia/src/test/java/com/imalittletester/jam/MonthHomeworkTest.java @@ -0,0 +1,56 @@ +package com.imalittletester.jam; + +import com.imalittletester.homeworks.MonthHomework; +import org.junit.jupiter.api.Test; + +import java.sql.SQLOutput; + +public class MonthHomeworkTest { + + @Test + void LastDayOfTheMonth() { + MonthHomework monthHomework = new MonthHomework(); + System.out.println(monthHomework.checkIfLastDayOfMonth("April", 28)); + System.out.println(monthHomework.checkIfLastDayOfMonth("September", 30)); + System.out.println(monthHomework.checkIfLastDayOfMonth("July", 31)); + System.out.println(monthHomework.checkIfLastDayOfMonth("August", 26)); + System.out.println(monthHomework.checkIfLastDayOfMonth("February", 28)); + System.out.println(monthHomework.checkIfLastDayOfMonth("February", 24)); + + } + + @Test + void numbersDivideBy7() { + for (int n = 1; n < 222; n++) { + if (n % 7 == 0) + System.out.println(n); + } + } + + @Test + void numbersDivide() { + for (int i = 1; i <= 222; i++) { + if (i / 7 == 1) + System.out.println(i); + } + } + + //@Test + //void numbersDivideSeven(){ + //for (int totalNumber = 222; totalNumber < 0; totalNumber++) { + //if (totalNumber % 7==0) + @Test + void testTen (){ + MonthHomework monthHomework = new MonthHomework(); + System.out.println(monthHomework.countNumbersDivided(35)); + } + + + } + + + + + + + diff --git a/iulia/src/test/java/com/imalittletester/jam/OperatorsTest.java b/iulia/src/test/java/com/imalittletester/jam/OperatorsTest.java new file mode 100644 index 0000000..46c75f6 --- /dev/null +++ b/iulia/src/test/java/com/imalittletester/jam/OperatorsTest.java @@ -0,0 +1,217 @@ +package com.imalittletester.jam; + +import org.junit.jupiter.api.Test; + +import javax.lang.model.SourceVersion; +import java.util.*; + +public class OperatorsTest { + + public int numele; + + + @Test + void firstTest() { + int int1 = 0; + int int2 = 55; + + double double1 = 0.0, double2 = 125.5; + + boolean bool1 = true, bool2 = false; + + String string1 = "", string2 = "This is the second string"; + + System.out.println("int1 = " + int1); + + int1 = 100; + System.out.println("int1 = " + int1); + + int2 = int1; + System.out.println("int2 = " + int2); + + int1 = int1 + 5; + System.out.println("int1 = " + int1); + + int1 = int2 + 10; + System.out.println("int1 = " + int1); + + double1 = 10.5 - 2.3; + System.out.println("double1 = " + double1); + + double1 = double2 - 1; + System.out.println("double1 = " + double1); + + double1 = double1 - double2; + System.out.println("double1 = " + double1); + + System.out.println(1 + 2); + System.out.println("1" + "2"); + System.out.println(1 + "2"); + + + System.out.println(!bool1); + System.out.println(!bool2); + boolean e = !"eeee".contains("e"); + + System.out.println(string1.equals(string2)); + + } + + @Test + void secondTest() { + int int1 = 1; + int cuiAsignamValoarea = 0; + //int 1 e 1 + cuiAsignamValoarea = int1++; //asignez valoarea veche, apoi updatez valoarea lui int1 + System.out.println("cuiAsignamValoarea = " + cuiAsignamValoarea); + //int1 e 2 deja + cuiAsignamValoarea = ++int1; //intai updatez valoarea lui int1, apoi o asignez + //int1 e 3 + System.out.println("cuiAsignamValoarea = " + cuiAsignamValoarea); + ++int1; + //int1 e 4 + System.out.println("int1 = " + int1); + int1++; + //int1 e 5 + System.out.println("int1 = " + int1); + + boolean int1MaiMareSauNu = int1 > cuiAsignamValoarea; + System.out.println("Int1 mai mare ca celalalt? " + int1MaiMareSauNu); + System.out.println("Int1 mai mic ca celalalt? " + (int1 < cuiAsignamValoarea)); + } + + @Test + void thirdTest() { + int int1 = 1; + //int1 = int1 + 10; + int1 += 10; + System.out.println("int1 = " + int1); //avem valoarea 11 + // int1 = int1 - 10; + int1 -= 10; + System.out.println("int1 = " + int1); //avem valoarea 1 + // int1 = int1 + -100000; + int1 += -100000; + System.out.println("int1 = " + int1); //valoarea -99999 + + System.out.println(1 == 2); + System.out.println(1 != 2); + } + + //Lists + @Test + void collectionTest() { + List lista1 = new ArrayList<>(); + System.out.println(lista1.isEmpty()); + lista1.add("Cluj"); + lista1.add("Oradea"); + System.out.println("lista1 = " + lista1); + + List lista2 = Arrays.asList("peach", "apple", "melon"); + System.out.println("lista2 = " + lista2); + System.out.println("Lista 2 contains apple: " + lista2.contains("apple")); + + List lista3 = List.of(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11); + System.out.println("lista3 = " + lista3); + System.out.println(lista3.get(5)); + System.out.println(lista3.size()); + + List listaDeNumere = List.of(5, 13, 25, 8, 14, 7, 9); + System.out.println(listaDeNumere.size()); + int numberOfNumbers = 0, number2 = 0; + + List positionInList = new ArrayList<>(); + for (int i = 0; i < listaDeNumere.size(); i++) { + if (listaDeNumere.get(i) % 7 == 0) { + numberOfNumbers++; + positionInList.add(i); + } + } + System.out.println("Number Of Numbers..." + numberOfNumbers); + System.out.println("Elements on the positions: " + positionInList); + + for (Integer numarInLista : listaDeNumere) { + if (numarInLista % 7 == 0) { + number2++; + } + } + System.out.println("number 2..." + number2); + } + + //Map + @Test + void mapTest() { + Map simpleMap = new HashMap<>(); + simpleMap.put("first", 1); + System.out.println("simpleMap= " + simpleMap); + + Map anotherMap = Map.of("firstKey", 1, "secondKey", 2, "thirdKey", 3); + System.out.println("anotherMap = " + anotherMap); + System.out.println("Is value present? " + anotherMap.containsValue(3)); + System.out.println("Is key present" + anotherMap.containsKey("secondKey")); + System.out.println("The value of second key is: " + anotherMap.get("secondKey")); + + System.out.println("The map size is: " + anotherMap.size()); + System.out.println("Is the map empty? " + anotherMap.isEmpty()); + + for (Map.Entry entry : anotherMap.entrySet()) { + System.out.println("Key: " + entry.getKey() + "value: " + entry.getValue()); + } + for (String key : anotherMap.keySet()) { + System.out.println(key); + } + for (int value : anotherMap.values()) + System.out.println(value); + } + + void sixthTest() { + for (int i = 0; i < 10; i++) { + System.out.println(i); + } + + System.out.println("---------------------"); + + + //numere divizibile cu 3 intre 0 si 21 (exclusiv) + + for (int i = 1; i < 21; i++) { + if (i % 3 == 0) + System.out.println(i); + } + System.out.println("---------------------------"); + for (int i = 20; i > 0; i--) { + if (i % 3 == 0) + System.out.println(i); + + System.out.println("----------------------"); + } + for (int i = 3; i < 20; i += 3) { + System.out.println(i); + } + System.out.println("--------------"); + int i = 1; + while (i < 21) { + if (i % 3 == 0) { + System.out.println(i); + } + i++; + } + + int position = 789; + + if (position > 0) + System.out.println("Element found on position " + position); + else System.out.println("THERE IS NO ELEMENT!!!!"); + + + // using simplified if + System.out.println(position > 0 ? "Element found on position: " + position : "THERE IS NO ELEMENT!!!"); + + String theMessage = position > 0 ? "Element found on position: " + position : "THERE IS NO ELEMENT!!!"; + String theMessage2 = ""; + if (position > 0) + theMessage2 = "Eelement found on position: " + position; + else theMessage2 = "THERE IS NO ELEMENT!"; + System.out.println(theMessage2); + } +} + diff --git a/iulia/src/test/java/com/imalittletester/jam/WatchTest.java b/iulia/src/test/java/com/imalittletester/jam/WatchTest.java new file mode 100644 index 0000000..2d4cc06 --- /dev/null +++ b/iulia/src/test/java/com/imalittletester/jam/WatchTest.java @@ -0,0 +1,27 @@ +package com.imalittletester.jam; + +import com.imalittletester.homeworks.Watch; +import org.junit.jupiter.api.Test; + +import java.sql.Timestamp; +import java.util.Date; + +public class WatchTest { + + public Watch watchData1 = new Watch("2022-11-17 12:23",3555,50000,"km",345,new Date(2022,18,17),5,12); + public Watch watchData2 = new Watch("2022-11-17 13:45",3555,50000,"miles",345,new Date(2022,18,17),5,13); + public Watch watchData3 = new Watch("2022-11-17 20:30",5096,54848,"km",567,new Date(2022,18,17),5,05); + + + @Test + void firstTest() { + watchData1.getWatchData(); + System.out.println("---------------------"); + watchData2.getWatchData(); + System.out.println("---------------------"); + watchData3.getWatchData(); + } + +} + + diff --git a/pom.xml b/pom.xml index 63fe07f..6507c1c 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,11 @@ com.imalittletester tutorial-java + pom 1.0-SNAPSHOT + + iulia + tutorial-java @@ -27,7 +31,6 @@ test -