From cd8bceee409aedd9d15aab1c055325c6b0c2f786 Mon Sep 17 00:00:00 2001 From: esoe Date: Fri, 14 Oct 2022 13:16:40 +0300 Subject: [PATCH] qq --- country/src/main/java/ru/molokoin/Area.java | 57 ++++++++++-------- .../src/main/java/ru/molokoin/Conversion.java | 24 -------- .../src/main/java/ru/molokoin/Country.java | 15 ++--- country/src/main/java/ru/molokoin/Map.java | 4 +- country/target/classes/ru/molokoin/Area.class | Bin 2421 -> 2695 bytes .../classes/ru/molokoin/Conversion.class | Bin 948 -> 0 bytes .../target/classes/ru/molokoin/Country.class | Bin 1715 -> 1824 bytes country/target/classes/ru/molokoin/Map.class | Bin 1631 -> 1624 bytes 8 files changed, 41 insertions(+), 59 deletions(-) delete mode 100644 country/src/main/java/ru/molokoin/Conversion.java delete 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 1ddfc0a..c8ed629 100644 --- a/country/src/main/java/ru/molokoin/Area.java +++ b/country/src/main/java/ru/molokoin/Area.java @@ -6,16 +6,9 @@ public class Area { private int square; Area(){ - //TODO сделать инициализацию полей как объектов и последующий каст в нужный тип - //чтобы была возможность обрабатывать null поля - //this(null,null,null); - //Area (Object name, Object population, Object square){} - - } - Area(Object name, int population, int square){ - init(name, population, square); + this(null, null, null); } - public void init(Object name, int population, int square){ + Area(Object name, Object population, Object square){ setName(name); setPopulation(population); setSquare(square); @@ -33,34 +26,46 @@ public class Area { try { if (name == null) throw new NullPointerException(getName()); } catch (Exception e) { - System.out.println("Наименвание не должно быть пустым. "); e.printStackTrace(); this.name = ""; + } finally{ + if (name != null) this.name = (String)name; } - try { - if((String)name == "")throw new IllegalArgumentException((String)name); - } catch (IllegalArgumentException e) { - System.out.println("Наименвание не должно быть пустым. "); - e.printStackTrace(); - this.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; + public void setPopulation(Object population) { + try { + if (population == null) throw new NullPointerException("Параметр {население} не задан ..."); + + } catch (NullPointerException e) { + e.printStackTrace(); + this.population = 0; + } finally{ + this.population = (Integer) population; + } } /** * @param square the square to set */ - public void setSquare(int square) { - if (square < 0) throw new IllegalArgumentException("площадь не может быть отрицательной ..."); - this.square = square; + public void setSquare(Object square) { + try { + if (square == null) throw new NullPointerException("Параметр {площадь} не задан ..."); + } catch (NullPointerException e) { + System.out.println("Наименвание не установлено ..."); + e.printStackTrace(); + this.square = 0; + } finally{ + this.square = (Integer) square; + } + try { + if (this.square < 0) throw new IllegalArgumentException("площадь не может быть отрицательной ..."); + + } catch (IllegalArgumentException e) { + e.printStackTrace(); + this.square = 0; + } } /** * @return the name diff --git a/country/src/main/java/ru/molokoin/Conversion.java b/country/src/main/java/ru/molokoin/Conversion.java deleted file mode 100644 index b2706d9..0000000 --- a/country/src/main/java/ru/molokoin/Conversion.java +++ /dev/null @@ -1,24 +0,0 @@ -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/Country.java b/country/src/main/java/ru/molokoin/Country.java index cc83f37..47540b2 100644 --- a/country/src/main/java/ru/molokoin/Country.java +++ b/country/src/main/java/ru/molokoin/Country.java @@ -5,21 +5,22 @@ public class Country extends Area{ public Country() { } - Country(String name, int population, int square){ - //this(name, population, square, null, null, null); - //TODO исключить дублирование метода Area.init() - this.init(name, population, square); + Country(Object name, Object population, Object square){ + super(name, population, square); } Country(String name, int population, int square, String capitalName, int capitalPopulation, int capitalSquare){ //параметры страны - this.init(name - , population - , square); + super(name, population, square); //параметры столицы if (capitalName != null) setCapital(new Area(capitalName , capitalPopulation , capitalSquare)); + if (capitalName == null){ + setCapital(new Area(null + , 0 + , 0)); + } } public static void print(Country country){ System.out.println("-------------------------------------------"); diff --git a/country/src/main/java/ru/molokoin/Map.java b/country/src/main/java/ru/molokoin/Map.java index af12201..f3f5ab1 100644 --- a/country/src/main/java/ru/molokoin/Map.java +++ b/country/src/main/java/ru/molokoin/Map.java @@ -10,13 +10,13 @@ public class Map { //Финляндия map[1] = new Country("Finland", 5500000, 338000, "Helsinki", 655000, 0); //Франция - map[2] = new Country("France", 67800000, 643800, "Paris", 2100000, 0); + map[4] = new Country("France", 67800000, 643800, "Paris", 2100000, 0); //Андора map[3] = new Country("Andorra", 85000, 647, "Andorra la Vella", 22600, 0); //Сингапур - map[4] = new Country("Singapore", 5700000, 725, "", 0, 0); + map[2] = new Country("Singapore", 5700000, 725, null, 0, 0); } public static void printAll(Country[] map){ System.out.println("printAll"); diff --git a/country/target/classes/ru/molokoin/Area.class b/country/target/classes/ru/molokoin/Area.class index 513758e99d6314620052ff268e89e752ea873f4d..539153d0c9b1c16b856bd9f76bbb57494e575fb3 100644 GIT binary patch literal 2695 zcma)7TW=dh7(J7lFWoeWo3w?d?Gj2!)`{KwB@V5Vl9=?8h9-mtD6nxB$L;!3$3`H8 z)D{T|(LaF1Ska$}E9wfw>-L<_*jfAZA?96wWbI$k8>|g)kGGyWKp0ct7i;>(ABzWrdUX4 zQ!#;HK9?_Fzdrim4&vP{r ziAbnK`Jq5po#!MOri?-mxA3t79ShWitmkyIL>xT6Jl3kGaE){!F#4Wu0BnnpHY?vq z6qSb!LHUsqIAi@lmvzaAxSvSCl7&N}@>S)2<$=AnNt?rQQxftaEzsxTVwy%uH%AMp zQpU&@YX$J*j=+Sq4U8+$Gi%c-OC42frSdK1e5evIRkhYDUsKfwQq{^s;@Px*bwpf} z^z$u~!=`<7I8AjDz)jdx;0!w}qJkXvc2;_ArOctvT_v+}-q5?ftsB zzsmf~&M1|<1UXjGf9Il4YERJ@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Kbk4X+ICobr(t)4kpomG6k3~L|+_R3XZp>&TN ztZ5!93_K$PMQ^2azbgNA=Ki(!wDc`)?u$+7q4!+ah{faa5I$45;%yLVz4RUVTo%eS zoBtb&K7SJ|PALmkJ*C`2+)j=Bx;dKR@oXWNa;~Ih_cY1^j0=M}!m`(LPu8MFCYGlf zX+r&GAMqX5|4r00dFtbvGmUy{6}ukuP=h^Mp@z>8>aZITo=jf}uOP~sfHVgH)6}UG z4FRxv+Yc7eQo-4+gV{rk2%2auSeCC}#*)>tPvh%(VFcn&g01CO?!my*EG6P8V)YiW z-)b+S-J-Wx#amR%n~B%L2wR!S-YSogvd2i-V?>i99wTLsM;WP4&iBL2Ns6bc}gQv0B=G zz%I!knv(dfwiOIj81$R&3|sdso2OrU-0RzwJ+|n=OYien@1^L@CVFx^`URq2B>Lb> z(4~C^o%=UHPw2Z$8vEuElkg|4fuBKwUYs(8Io#R7c<9${#v?l#r*||?Za2QUqw!ts GV*WpkJ06+< diff --git a/country/target/classes/ru/molokoin/Conversion.class b/country/target/classes/ru/molokoin/Conversion.class deleted file mode 100644 index 4ff1b4f98ce75a533613fb9e35d83573b70a4a2c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 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 diff --git a/country/target/classes/ru/molokoin/Country.class b/country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&yN3ZfdE>Nvtq0>2*zmn>`~wN3W1s*4 diff --git a/country/target/classes/ru/molokoin/Map.class b/country/target/classes/ru/molokoin/Map.class index 0e476c0a591b071827ae824a9983a034532d18ff..e6dbc04f319ae8f2ac457c32232f4c3de4d19ffc 100644 GIT binary patch delta 398 zcmXYr%S!@L6o-FzMpK7djiW@7M1%xcB#PS0-qTxqsnzs!N(-e7OoDb5ZCYP~pna{2 zFiB|DrWWmlTJ=w~j;LNa{rCjHgY8@Cg|H9O($I-+6S@fGw0@|& zclFGUJ92c8OYTwhAjlepMyFpwKL$-0Ah7*XseSisHkHXma@nNL!66K@gy1A2>|Ah= zF?KDa6%`W{CJakZF+~wVm^Fzmvx*stSb(WbvkPN5uzA#8?|j}K%v=(oA{Ii8#)PP^j(#XZF{q&ot-5MDMwrT&Hffh_*A_j? zZo0E3GQ=cy7P{%8k=XS=@F$3K)uK7cdEfV!=Y8^C$iLG1b#;6Kw6nHnoe5unE&=L~ zXsPcb=I5axwC;R#q8m;w6HR{FE~Gal{X9~&Mnhw_#Z#X784y(7P}%pSLce!