From 858841654e203627fcae85cab7845bc989c10368 Mon Sep 17 00:00:00 2001 From: BalNatalia Date: Mon, 4 Sep 2017 10:33:18 +0300 Subject: [PATCH 1/4] New file --- Bal.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 Bal.txt diff --git a/Bal.txt b/Bal.txt new file mode 100644 index 0000000..2491f25 --- /dev/null +++ b/Bal.txt @@ -0,0 +1 @@ + \ No newline at end of file From bd661d9695b5974ecb4346fa8c732da7155e6992 Mon Sep 17 00:00:00 2001 From: BalNatalia <31563197+BalNatalia@users.noreply.github.com> Date: Mon, 4 Sep 2017 10:41:04 +0300 Subject: [PATCH 2/4] Delete Bal.txt --- Bal.txt | 1 - 1 file changed, 1 deletion(-) delete mode 100644 Bal.txt diff --git a/Bal.txt b/Bal.txt deleted file mode 100644 index 2491f25..0000000 --- a/Bal.txt +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file From bd29df615168962dc6289e59862533d9dfa1ee86 Mon Sep 17 00:00:00 2001 From: BalNatalia <31563197+BalNatalia@users.noreply.github.com> Date: Sun, 3 Dec 2017 13:04:28 +0300 Subject: [PATCH 3/4] Add files via upload --- DataBase/build.xml | 73 + .../build/classes/database/DataBase.class | Bin 0 -> 5114 bytes DataBase/manifest.mf | 3 + DataBase/nbproject/build-impl.xml | 1420 +++++++++++++++++ DataBase/nbproject/genfiles.properties | 8 + DataBase/nbproject/private/private.properties | 2 + DataBase/nbproject/private/private.xml | 7 + DataBase/nbproject/project.properties | 76 + DataBase/nbproject/project.xml | 15 + DataBase/src/database/DataBase.java | 176 ++ 10 files changed, 1780 insertions(+) create mode 100644 DataBase/build.xml create mode 100644 DataBase/build/classes/database/DataBase.class create mode 100644 DataBase/manifest.mf create mode 100644 DataBase/nbproject/build-impl.xml create mode 100644 DataBase/nbproject/genfiles.properties create mode 100644 DataBase/nbproject/private/private.properties create mode 100644 DataBase/nbproject/private/private.xml create mode 100644 DataBase/nbproject/project.properties create mode 100644 DataBase/nbproject/project.xml create mode 100644 DataBase/src/database/DataBase.java diff --git a/DataBase/build.xml b/DataBase/build.xml new file mode 100644 index 0000000..c138705 --- /dev/null +++ b/DataBase/build.xml @@ -0,0 +1,73 @@ + + + + + + + + + + + Builds, tests, and runs the project DataBase. + + + diff --git a/DataBase/build/classes/database/DataBase.class b/DataBase/build/classes/database/DataBase.class new file mode 100644 index 0000000000000000000000000000000000000000..7110fd5349658b7dffa954fd7497338959307f8a GIT binary patch literal 5114 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 xOOBG`5t#NqGA^t$N{ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set src.dir + Must set test.src.dir + Must set build.dir + Must set dist.dir + Must set build.classes.dir + Must set dist.javadoc.dir + Must set build.test.classes.dir + Must set build.test.results.dir + Must set build.classes.excludes + Must set dist.jar + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + No tests executed. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set JVM to use for profiling in profiler.info.jvm + Must set profiler agent JVM arguments in profiler.info.jvmargs.agent + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + To run this application from the command line without Ant, try: + + java -jar "${dist.jar.resolved}" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + Must select one file in the IDE or set run.class + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set debug.class + + + + + Must select one file in the IDE or set debug.class + + + + + Must set fix.includes + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + Must select one file in the IDE or set profile.class + This target only works when run from inside the NetBeans IDE. + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + + + Must select some files in the IDE or set test.includes + + + + + Must select one file in the IDE or set run.class + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + Some tests failed; see details above. + + + + + + + + + Must select some files in the IDE or set test.includes + + + + Some tests failed; see details above. + + + + Must select some files in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + Some tests failed; see details above. + + + + + Must select one file in the IDE or set test.class + + + + Must select one file in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + + + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/DataBase/nbproject/genfiles.properties b/DataBase/nbproject/genfiles.properties new file mode 100644 index 0000000..af48843 --- /dev/null +++ b/DataBase/nbproject/genfiles.properties @@ -0,0 +1,8 @@ +build.xml.data.CRC32=c402950b +build.xml.script.CRC32=33632e37 +build.xml.stylesheet.CRC32=8064a381@1.80.1.48 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. +nbproject/build-impl.xml.data.CRC32=c402950b +nbproject/build-impl.xml.script.CRC32=90930164 +nbproject/build-impl.xml.stylesheet.CRC32=830a3534@1.80.1.48 diff --git a/DataBase/nbproject/private/private.properties b/DataBase/nbproject/private/private.properties new file mode 100644 index 0000000..3110b41 --- /dev/null +++ b/DataBase/nbproject/private/private.properties @@ -0,0 +1,2 @@ +compile.on.save=true +user.properties.file=C:\\Users\\\u041d\u0430\u0442\u0430\u0448\u0430\\AppData\\Roaming\\NetBeans\\8.2\\build.properties diff --git a/DataBase/nbproject/private/private.xml b/DataBase/nbproject/private/private.xml new file mode 100644 index 0000000..284eeec --- /dev/null +++ b/DataBase/nbproject/private/private.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/DataBase/nbproject/project.properties b/DataBase/nbproject/project.properties new file mode 100644 index 0000000..68632bb --- /dev/null +++ b/DataBase/nbproject/project.properties @@ -0,0 +1,76 @@ +annotation.processing.enabled=true +annotation.processing.enabled.in.editor=false +annotation.processing.processor.options= +annotation.processing.processors.list= +annotation.processing.run.all.processors=true +annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output +build.classes.dir=${build.dir}/classes +build.classes.excludes=**/*.java,**/*.form +# This directory is removed when the project is cleaned: +build.dir=build +build.generated.dir=${build.dir}/generated +build.generated.sources.dir=${build.dir}/generated-sources +# Only compile against the classpath explicitly listed here: +build.sysclasspath=ignore +build.test.classes.dir=${build.dir}/test/classes +build.test.results.dir=${build.dir}/test/results +# Uncomment to specify the preferred debugger connection transport: +#debug.transport=dt_socket +debug.classpath=\ + ${run.classpath} +debug.test.classpath=\ + ${run.test.classpath} +# \u0424\u0430\u0439\u043b\u044b \u0432 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0435 build.classes.dir, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0438\u0437 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u044f\u0435\u043c\u043e\u0433\u043e \u0430\u0440\u0445\u0438\u0432\u0430 jar +dist.archive.excludes= +# This directory is removed when the project is cleaned: +dist.dir=dist +dist.jar=${dist.dir}/DataBase.jar +dist.javadoc.dir=${dist.dir}/javadoc +excludes= +file.reference.com.mysql.jdbc_5.1.5.jar=C:\\Users\\\u041d\u0430\u0442\u0430\u0448\u0430\\Desktop\\com.mysql.jdbc_5.1.5.jar +includes=** +jar.compress=false +javac.classpath=\ + ${file.reference.com.mysql.jdbc_5.1.5.jar} +# Space-separated list of extra javac options +javac.compilerargs= +javac.deprecation=false +javac.external.vm=true +javac.processorpath=\ + ${javac.classpath} +javac.source=1.8 +javac.target=1.8 +javac.test.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +javac.test.processorpath=\ + ${javac.test.classpath} +javadoc.additionalparam= +javadoc.author=false +javadoc.encoding=${source.encoding} +javadoc.noindex=false +javadoc.nonavbar=false +javadoc.notree=false +javadoc.private=false +javadoc.splitindex=true +javadoc.use=true +javadoc.version=false +javadoc.windowtitle= +main.class=database.DataBase +manifest.file=manifest.mf +meta.inf.dir=${src.dir}/META-INF +mkdist.disabled=false +platform.active=default_platform +run.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +# Space-separated list of JVM arguments used when running the project. +# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value. +# To set system properties for unit tests define test-sys-prop.name=value: +run.jvmargs= +run.test.classpath=\ + ${javac.test.classpath}:\ + ${build.test.classes.dir} +source.encoding=UTF-8 +src.dir=src +test.src.dir=test diff --git a/DataBase/nbproject/project.xml b/DataBase/nbproject/project.xml new file mode 100644 index 0000000..ade5d29 --- /dev/null +++ b/DataBase/nbproject/project.xml @@ -0,0 +1,15 @@ + + + org.netbeans.modules.java.j2seproject + + + DataBase + + + + + + + + + diff --git a/DataBase/src/database/DataBase.java b/DataBase/src/database/DataBase.java new file mode 100644 index 0000000..ba9a693 --- /dev/null +++ b/DataBase/src/database/DataBase.java @@ -0,0 +1,176 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package database; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * + * @author Наташа + */ +public class DataBase { + public static Connection conn; + public static Statement state; + // private static int id; + public static ResultSet rs; + + private static void connect() { + try { + Class.forName("com.mysql.jdbc.Driver"); + } catch (ClassNotFoundException ex) { + System.out.println("Can't find this class."); + } + try { + conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/banan", "root", "4444"); + state = conn.createStatement(); + conn.setAutoCommit(false); + + } catch (SQLException ex) { + System.out.println("Excepion connection"); + } + + } + + public static void createTable() { + connect(); + try { + state.execute("CREATE TABLE user(id int PRIMARY KEY NOT NULL, login varchar(15), age int NOT NULL);"); + state.execute("CREATE TABLE passward (idPas int PRIMARY KEY NOT NULL, pass varchar(8));"); + conn.commit(); + conn.close(); + } catch (SQLException ex) { + System.out.println("Exception creation"); + try { + conn.rollback(); + conn.close(); + } catch (SQLException ex1) { + System.out.println("Exeption rollback"); + } + } + } + + public static void addElement(String name, int age, String pas) { + connect(); + try { + state.executeUpdate("INSERT INTO user (login, age) VALUES ('"+name+"', '"+age+"')"); + state.executeUpdate("INSERT INTO passward (pass) values ( '"+pas+"')"); + conn.commit(); + conn.close(); + System.out.println("Success!!"); + } catch (SQLException ex) { + System.out.println("Element wasn't added"); + try { + conn.rollback(); + conn.close(); + } catch (SQLException ex1) { + } + } + + + } + + public static void delete (String name) { + connect(); + int idF = 0; + try { + rs = state.executeQuery("SELECT * FROM user WHERE login = '"+name+"'"); + if (rs != null) { + while (rs.next()) { + idF = rs.getInt("id"); + } + state.executeUpdate("DELETE FROM user WHERE login = '"+name+"'"); + state.execute("DELETE FROM passward WHERE idPas = "+idF+""); + } + else { + System.out.println("There is no user with this login"); + } + conn.commit(); + conn.close(); + System.out.println("User was deleted"); + } catch (SQLException ex) { + System.out.println("You can't delete it"); + try { + conn.rollback(); + conn.close(); + } catch (SQLException ex1) { + System.out.println("You didn't delete this element"); + } + } + } + + public static void checkUser(String log, String pass) { + int idPa=0; + String pass2 = null; + connect(); + try { + rs = state.executeQuery("SELECT * FROM user WHERE login = '"+log+"';"); + if (rs != null) { + while(rs.next()) { + System.out.println(rs.getInt("id")); + idPa = rs.getInt("id"); + } + rs = state.executeQuery("SELECT pass FROM passward WHERE idPas = '"+idPa+"';"); + while (rs.next()) + pass2 = rs.getString("pass"); + if (pass.equals(pass2)) { + System.out.println("There is this user. Passward is right"); + } + else { + System.out.println("Passward isn't right"); + } + } + else { + System.out.println("There is no user with this name"); + } + conn.commit(); + conn.close(); + } catch (SQLException ex) { + System.out.println("Exception one"); + try { + conn.rollback(); + conn.close(); + } catch (SQLException ex1) { + System.out.println("Cannot rollback"); + } + } + + } + + public static void result() { + connect(); + try { + rs = state.executeQuery("SELECT * FROM user"); + while (rs.next()) { + System.out.print(rs.getInt("id") + " "); + System.out.print(rs.getString("login") + " "); + System.out.println(rs.getInt("age") + " "); + } + conn.commit(); + conn.close(); + } catch (SQLException ex) { + try { + conn.rollback(); + conn.close(); + } catch (SQLException ex1) { + } + } + + } + + /** + * @param args the command line arguments + */ + public static void main(String[] args) { + + } + +} From 2db5c1eae48a9f3d5cd94f5cdb20243fdc534284 Mon Sep 17 00:00:00 2001 From: BalNatalia <31563197+BalNatalia@users.noreply.github.com> Date: Sun, 3 Dec 2017 13:06:06 +0300 Subject: [PATCH 4/4] Add files via upload --- Calculator/pom.xml | 27 +++++++ .../com/mycompany/calculator/Calculator.java | 40 ++++++++++ Calculator/src/test/java/NewTest.java | 64 ++++++++++++++++ .../com/mycompany/calculator/Calculator.class | Bin 0 -> 1003 bytes .../target/surefire-reports/NewTest.txt | 4 + .../target/surefire-reports/TEST-NewTest.xml | 70 ++++++++++++++++++ Calculator/target/test-classes/NewTest.class | Bin 0 -> 1629 bytes 7 files changed, 205 insertions(+) create mode 100644 Calculator/pom.xml create mode 100644 Calculator/src/main/java/com/mycompany/calculator/Calculator.java create mode 100644 Calculator/src/test/java/NewTest.java create mode 100644 Calculator/target/classes/com/mycompany/calculator/Calculator.class create mode 100644 Calculator/target/surefire-reports/NewTest.txt create mode 100644 Calculator/target/surefire-reports/TEST-NewTest.xml create mode 100644 Calculator/target/test-classes/NewTest.class diff --git a/Calculator/pom.xml b/Calculator/pom.xml new file mode 100644 index 0000000..c4f8d9f --- /dev/null +++ b/Calculator/pom.xml @@ -0,0 +1,27 @@ + + + 4.0.0 + com.mycompany + Calculator + 1.0-SNAPSHOT + jar + + + junit + junit + 4.12 + test + + + org.hamcrest + hamcrest-core + 1.3 + test + + + + UTF-8 + 1.8 + 1.8 + + \ No newline at end of file diff --git a/Calculator/src/main/java/com/mycompany/calculator/Calculator.java b/Calculator/src/main/java/com/mycompany/calculator/Calculator.java new file mode 100644 index 0000000..9e3c52e --- /dev/null +++ b/Calculator/src/main/java/com/mycompany/calculator/Calculator.java @@ -0,0 +1,40 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package com.mycompany.calculator; + +/** + * + * @author Наташа + */ +public class Calculator { +float c; + public Calculator() { + } + + public float add(float a, float b) { + c= a+b; + return c; + } + public float sub(float a, float b) { + c = a-b; + return c; + } + public float mul(float a, float b) { + c = a*b; + return c; + } + public long div(long a, long b) { + try { + return a/b; + }catch (java.lang.ArithmeticException e) { + throw new ArithmeticException(); + } + } + + public static void main(String[] args) { + + } +} diff --git a/Calculator/src/test/java/NewTest.java b/Calculator/src/test/java/NewTest.java new file mode 100644 index 0000000..4feff92 --- /dev/null +++ b/Calculator/src/test/java/NewTest.java @@ -0,0 +1,64 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ + +import com.mycompany.calculator.Calculator; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import static org.junit.Assert.*; + + +/** + * + * @author Наташа + */ +public class NewTest { + private Calculator calc; + public NewTest() { + } + + @BeforeClass + public static void setUpClass() { + + } + + @AfterClass + public static void tearDownClass() { + } + + @Before + public void setUp() { + calc = new Calculator(); + } + + @After + public void tearDown() { + } + @Test + public void divNZ(){ + assertTrue(calc.div(24, 12) == 2); + } + @Test + public void mulTest(){ + assertTrue(calc.mul(45, 15) == 675); + } + @Test(expected = ArithmeticException.class) + public void divZero(){ + calc.div(12,0); + } + + @Test + public void addT(){ + assertTrue(calc.add(56, 45) == 101); + } + @Test + public void subT(){ + assertTrue(calc.sub(56, 12) == 44); + } + +} diff --git a/Calculator/target/classes/com/mycompany/calculator/Calculator.class b/Calculator/target/classes/com/mycompany/calculator/Calculator.class new file mode 100644 index 0000000000000000000000000000000000000000..18c6fb28e1d9602c19513a3f6a9078d6a55fceeb GIT binary patch literal 1003 zcma)4L2nX47=6P63rN9IMWt4tv=%UtgPyE0F;xx(>jBfmc$!_dbdcR8+ug?gC{0W> zO*GNFKg#%KLCb*}4)g6d-@JM6oA>Rn-`{=!c#ORq(%8--g@%cp91Lum*fnuqK-gSe zf%H@5sqmSA(QF+FBoF+dBT(!s&pC`-%L(2{Yr;yY@7r>6Bm<@Q^I|eQQKtgCecN|C z?m6RBdgmPi?PwxHKj<9%OZO=uheLr>v)gS^Sx7F6)ze5vH<~aG)tN^0daWK$sax%j z<(ceEq&Mn34^(*KI-#;(ez2WssCU^`u<-(9?X!9(3i9$Dn_Fp&}1`fqCjjTLMWxPHm<+8R4{h&l(B z<^Tm3g&5P!smpkcyGQ)$vsC*6;xm&3@{BotfdY~!VvSjT24bbi9fh#Ys0j}FCm0&h zZtPfJk!XKG;uH6aJS9qR#5}bbcFv=DOKeIvkS8L;TLL$havxv8T_*RfmAP*&DGT^s2(Un>^<@Uzp6ZxQng1{sY#vrwaqsQwR29iP + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Calculator/target/test-classes/NewTest.class b/Calculator/target/test-classes/NewTest.class new file mode 100644 index 0000000000000000000000000000000000000000..66b230a4aa6485be34c78aabdeea2ad2f456df08 GIT binary patch literal 1629 zcmb7FTTc@~6#k~&y0&fwDR17@z%7#&5RUvet;Y4>RY?obz2~rs?+|pT7c_#9|5qxTxb&3Nc(vVm~e?xS_s* zc3`NzEA1?n!W5>p;v}FI>VVq3s?BG=K`TCNrPs9LceOj)N@uj<1fb)(j#&ZCGOL!r zXxVaW`Pxg4b<=s7SF6pc>APNjt`klR?6_(>wm%~f&*oOyJ?B=WKu_6rqL*(JoP>Dej|7d8Kh-4IBYm*n#m+3<;%YDoWHeXeRYxG{LQ>G*a{uG$ToT?NN+ zebcvHhkN_WuJ<^<(Ik7mC?C0=44Md$_ND2~yU(2vr9ViaHLEHV(Al&mJ(uY6MO|9HtO$&hH_T^d zzG^y;^99fLpVXvpTMI8NSyxucrJ0q=3a3VMol|PrZF-h0+3Hx0@Z`=Y3he(sAJB+JQfU;aKpe&HQd4tiVdL!dbb4LS>K>+-Zq`^5VDJlxkVOiT}7eM zkRA(Cyg&vkUXv=d?3#KUaUO(fDwT32W^~1orf`JsdVo(_@U2o8qZDJB;W*6fJZHf< zG4>JS9fKGS1w}EA{m|Gx!pLY9;V=P#B#sgw761$~S6|R9g617T@j)EpvWky$PGa=$ zEr&ZTCln%1c3P$o4?vBvFNi((i1-I+-D;0x7fH6%8ll>@jBJ3J>tK!td8oW)yQMrA z0TEpwV?on+2V@nAK-louduV+~^g-W5vJa_OZ=h>$p~XMJP)g&Gb3MiO(-D&4kmMBW z5{M1V@})6UYEB1yXF7b#;Xw>3zDzo^dlNmG-q+iZP4M2&M#zSKCENEKS-wLy9hytG z%;`y5yWf56lYAT(BKYaZiR}s;2uxU%AaJgO{Hu*Une-+ynZ4WDxI!CK5t_f+IR8ho YzD?}Q^lwLYjbt