From 75ddf84c0cac4872c264537ac8b7ef2d02123e01 Mon Sep 17 00:00:00 2001 From: esoe Date: Fri, 14 Oct 2022 11:39:42 +0300 Subject: [PATCH] conversion --- country/src/main/java/ru/molokoin/Area.java | 21 ++++++++++----- .../src/main/java/ru/molokoin/Conversion.java | 24 ++++++++++++++++++ country/src/main/java/ru/molokoin/Map.java | 2 +- country/target/classes/ru/molokoin/Area.class | Bin 2162 -> 2421 bytes .../classes/ru/molokoin/Conversion.class | Bin 0 -> 948 bytes .../target/classes/ru/molokoin/Country.class | Bin 1689 -> 1715 bytes country/target/classes/ru/molokoin/Map.class | Bin 1631 -> 1631 bytes 7 files changed, 40 insertions(+), 7 deletions(-) create mode 100644 country/src/main/java/ru/molokoin/Conversion.java create mode 100644 country/target/classes/ru/molokoin/Conversion.class diff --git a/country/src/main/java/ru/molokoin/Area.java b/country/src/main/java/ru/molokoin/Area.java index 7671d74..1ddfc0a 100644 --- a/country/src/main/java/ru/molokoin/Area.java +++ b/country/src/main/java/ru/molokoin/Area.java @@ -12,10 +12,10 @@ public class Area { //Area (Object name, Object population, Object square){} } - Area(String name, int population, int square){ + Area(Object name, int population, int square){ init(name, population, square); } - public void init(String name, int population, int square){ + public void init(Object name, int population, int square){ setName(name); setPopulation(population); setSquare(square); @@ -28,20 +28,29 @@ public class Area { /** * @param name the name to set */ - public void setName(String name) { + public void setName(Object name) { + //преобразование Object try { - if(name == "")throw new IllegalArgumentException(name); + if (name == null) throw new NullPointerException(getName()); + } catch (Exception e) { + System.out.println("Наименвание не должно быть пустым. "); + e.printStackTrace(); + this.name = ""; + } + try { + if((String)name == "")throw new IllegalArgumentException((String)name); } catch (IllegalArgumentException e) { System.out.println("Наименвание не должно быть пустым. "); e.printStackTrace(); - this.name = name; + this.name = ""; } - this.name = name; + if (name != null) this.name = (String)name; } /** * @param population the population to set */ public void setPopulation(int population) { + //население не может быть отрицательным if (population < 0) throw new IllegalArgumentException("Население не может быть отрицательным ..."); this.population = population; diff --git a/country/src/main/java/ru/molokoin/Conversion.java b/country/src/main/java/ru/molokoin/Conversion.java new file mode 100644 index 0000000..b2706d9 --- /dev/null +++ b/country/src/main/java/ru/molokoin/Conversion.java @@ -0,0 +1,24 @@ +package ru.molokoin; + +public class Conversion { + /** + * Проверяем содержимое объекта. + * + * @param object + * @return + */ + public static Object checknull(Object object){ + Object result = new Object(); + if (object == null)throw new NullPointerException("Обнаружено пустое поле данных ..."); + + return (Object)result; + } + public static int toint(Object object){ + String s = (String) object; + return Integer.parseInt(s); + } + public static String toString(Object object){ + + return ""; + } +} diff --git a/country/src/main/java/ru/molokoin/Map.java b/country/src/main/java/ru/molokoin/Map.java index c5dbd7b..af12201 100644 --- a/country/src/main/java/ru/molokoin/Map.java +++ b/country/src/main/java/ru/molokoin/Map.java @@ -28,7 +28,7 @@ public class Map { } } public static void main(String[] args) { - System.out.println("App.main()"); + System.out.println("Map.main()"); Map terra = new Map(); terra.initDefaults(); printAll(terra.map); diff --git a/country/target/classes/ru/molokoin/Area.class b/country/target/classes/ru/molokoin/Area.class index 3b8f2faf662cfda42b63c79435e2fd75862ec793..513758e99d6314620052ff268e89e752ea873f4d 100644 GIT binary patch delta 1231 zcmZuwNl#Nz6#i~Y`$~B-JY*~gmQv{}bCFqwYSqdt$e#u5>$rVBen4tYw_T+j9S$3EmoP)z)-~V z3`K<&G%=W?q}o|&MLj$+tZ3octkhDERvB$*=f7ANHJviL(9Jythq(uR5_*5Z^aBw>!h&Nqy9rxmmCh_7h|Cf?Jr z*OVsj;xVI(J?7iS5%z@tG!F3ojNhz?drXa4#cEjsWomf>l{{){wG~kcAXlsm2EC$X zz(~JV@dH!AyhCxmM%jDR?4y20Y1~7z`T>pvt|ritz%^>Tua4$7l5=kYH`81cUGYi8ea!9gSH(;k#R3Q%zl%N{ra8l}^Jb zg^{i;Z?fd8j(2G(Gm(PwiBz&)n^LJ5LU^jfy>Cy!2hN3ulkj@~Y53T=@I{?;=|7+* B(=1bxYM{YA>KDFU>ee7`sUtq&pGeR{iFVJ*gx;S{|KNTcc0q7 zhSS<|zAzt6B)aG9V5nEnfI0?CzL3{Mp-DkAoD9-RPMgdw=J;RcTw`!4XoZ{M2$iRc zOREc6Enh6qoWD%uQE*%UstAyNxSCzgF<6&KORFMQuL3JrQkFo{GQ1>H-fVg&M?&NaZL+L6hbabYUhlb8ZH+K!smGf5@Z<{7?h>` zYnH^ugv2F^!k^$HCTEMlk1KQ?!e3^PSBzUnJQ7m;o7rbeVnD_ePnpN)IHO>eubYp_ z42+WTrucVryCo`Pj?Y@A*meHWl9Z+Sa^^oRznP8iSi{wg0hf-JK&y^6?z9b2b;j1b z){bftSLmxghlNhS{lGhPsGYCidJEq+dNXQh3;m*~B)cC{A;u&We-narXS!7s-3Ul-bOML+``1C39_P2l5&rZ=|FH3 z9mZqBFkDMa$uggtLI&VIGm&%(S$7BiHsu;*}$VG%`dZ!~B`t z=FcEPS|a@r{fqRiBItEGl=2a_fDyhU*ZXha<{{wNn+ou#0lsx8I9>@J7hvhOL2>6F DA+xp4 diff --git a/country/target/classes/ru/molokoin/Conversion.class b/country/target/classes/ru/molokoin/Conversion.class new file mode 100644 index 0000000000000000000000000000000000000000..4ff1b4f98ce75a533613fb9e35d83573b70a4a2c GIT binary patch literal 948 zcmah{%Wl(95Ir|eV#iIJ#Ly64ZOWtM0f|@#v7iDel2wpeRqE0)SE*aqt{kUg2~@23 z2flzsDp87vnzBP;W&aRjZfrswMd3Y4Q3Eu{z;Dihk zL!o>M1{6LE--qwYjYdO79*cr(kzsLqt_|O_oNh~OCGE!B(k>23QIGffHtjOyi{WNq zqD8l=Z5cQJ`hf^v#WGf8lo<*WqHUtsAW0fs3cWH}O_EfORP7YXF)0bC z^olU3V2<8wlt6NxtPB>ABabNFq>Kc~(h$-%)$6tIm>(j)t!byYd|n?=EW%qDH=lz- zC`CdLxW%XzS5P8Lp>MrP8XX?4;dRvc_kiS>nO2z$7m+Pak(FW)hT6DY{TCw8-A@1j literal 0 HcmV?d00001 diff --git a/country/target/classes/ru/molokoin/Country.class b/country/target/classes/ru/molokoin/Country.class index 128210a232cc04bdb834904fb5ffa39d2b957e79..9d18c289b6f0ac91fafa47df07fe488b59f81b36 100644 GIT binary patch delta 457 zcmYL_%SyvQ7=_QINuwdfpw-q}FVV&}HAZXIYO&r0K~NC7k5V;7E7YI}K7k8CW+g6t z120{;a4Y%(K7-F7h<{6~%wi7bKmYldxeYu9l#id6R{#@OzfnH*AcN>uT#q4?+$=k1 zj(y}*4(zSna%s=YZ)~KBH(!U^fC?Ew1q=}tQN*~zE+ZpI$w)G2|7$xJr(Wq;g^4u( zW--xXB;rCUVOa`nOvo5#=xXHM6MMVrR=gdrT5@P5gGqiY7}}JIVYJmzGb(bJ<@drJ zTj2}7w`ezd$Ocq|5QflDy`+4kWc2ZbXo>wb4DzD5U2cW-zp##0SVx?yL|W77gdsK5 z5Gg;}37;TLJ9+yAsbeA!FgizT7&AB1HDt{irs-;#T$3^#bLgO;f*|r#!uXYB@N=n$ z>z1=PO`=ze~B;B9^F{)xWTbC^Qj%GyRNZ9`|QM^yuc$ZiE5Je4^Qr-;h@cB4F(o DEbB`x delta 438 zcmX|7$w~uJ5Ue*#CK)C;Xm-uwM59iOV>D_sm>8Fvhkz%KIk-e(6bynWc+<1=N&E`8 z90a`z`2jz`{}9_Dkq7V9tE%p5`q_W)*SkM&9{}>$y3@bBrhw9DHQFSLLvz@G22+PX z+&}_Jx)fK53??;92$)Cp^SaZlw+@`0i?jCLv4JVr6qHiRv_O`sQkrU#*Q;X&vl<*~ zN)b7aIl7fHX2C!jED0Gtv;Hijq@e9gNVa zQoHV(t$(wHzS%;GTPa*-VU!!FF0vST;N$o)j`1wze|h*3q24=rPW|2hI#VMXvM(TQ55mYSxn8j@F0rf;>Fs$k7kd6B*3 iaxd9qXJ1jJlBW>nUGzl9H3O>s!rF}|qiwh&Z2kg})IGBR diff --git a/country/target/classes/ru/molokoin/Map.class b/country/target/classes/ru/molokoin/Map.class index f6ef87f0d95d3c911dbb13dd9f5d81a6930a56b9..0e476c0a591b071827ae824a9983a034532d18ff 100644 GIT binary patch delta 15 Wcmcc5bDw9!MP?@7#LbtPdzb(<-v%N8 delta 15 Wcmcc5bDw9!MP??)g3Xtidzb(<