diff --git a/Task3/.idea/.gitignore b/Task3/.idea/.gitignore new file mode 100644 index 0000000..73f69e0 --- /dev/null +++ b/Task3/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/Task3/.idea/description.html b/Task3/.idea/description.html new file mode 100644 index 0000000..db5f129 --- /dev/null +++ b/Task3/.idea/description.html @@ -0,0 +1 @@ +Simple Java application that includes a class with main() method \ No newline at end of file diff --git a/Task3/.idea/encodings.xml b/Task3/.idea/encodings.xml new file mode 100644 index 0000000..97626ba --- /dev/null +++ b/Task3/.idea/encodings.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Task3/.idea/libraries/lib.xml b/Task3/.idea/libraries/lib.xml new file mode 100644 index 0000000..fa8838a --- /dev/null +++ b/Task3/.idea/libraries/lib.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/Task3/.idea/misc.xml b/Task3/.idea/misc.xml new file mode 100644 index 0000000..00b4bc4 --- /dev/null +++ b/Task3/.idea/misc.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/Task3/.idea/modules.xml b/Task3/.idea/modules.xml new file mode 100644 index 0000000..c328437 --- /dev/null +++ b/Task3/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/Task3/.idea/project-template.xml b/Task3/.idea/project-template.xml new file mode 100644 index 0000000..1f08b88 --- /dev/null +++ b/Task3/.idea/project-template.xml @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/Task3/.idea/runConfigurations.xml b/Task3/.idea/runConfigurations.xml new file mode 100644 index 0000000..797acea --- /dev/null +++ b/Task3/.idea/runConfigurations.xml @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/Task3/.idea/uiDesigner.xml b/Task3/.idea/uiDesigner.xml new file mode 100644 index 0000000..e96534f --- /dev/null +++ b/Task3/.idea/uiDesigner.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Task3/Task3.iml b/Task3/Task3.iml new file mode 100644 index 0000000..18eadff --- /dev/null +++ b/Task3/Task3.iml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Task3/lib/json-simple-1.1.jar b/Task3/lib/json-simple-1.1.jar new file mode 100644 index 0000000..f395f41 Binary files /dev/null and b/Task3/lib/json-simple-1.1.jar differ diff --git a/Task3/out/production/Task3/com/lib/EmailValidator.class b/Task3/out/production/Task3/com/lib/EmailValidator.class new file mode 100644 index 0000000..3b73dbf Binary files /dev/null and b/Task3/out/production/Task3/com/lib/EmailValidator.class differ diff --git a/Task3/out/production/Task3/com/lib/PasswordChecker.class b/Task3/out/production/Task3/com/lib/PasswordChecker.class new file mode 100644 index 0000000..0ed1da6 Binary files /dev/null and b/Task3/out/production/Task3/com/lib/PasswordChecker.class differ diff --git a/Task3/out/production/Task3/com/lib/PhoneValidator.class b/Task3/out/production/Task3/com/lib/PhoneValidator.class new file mode 100644 index 0000000..0e77063 Binary files /dev/null and b/Task3/out/production/Task3/com/lib/PhoneValidator.class differ diff --git a/Task3/out/production/Task3/com/lib/files/phones.json b/Task3/out/production/Task3/com/lib/files/phones.json new file mode 100644 index 0000000..f6f00b4 --- /dev/null +++ b/Task3/out/production/Task3/com/lib/files/phones.json @@ -0,0 +1 @@ +{"BD": "880", "BE": "32", "BF": "226", "BG": "359", "BA": "387", "BB": "1-246", "WF": "681", "BL": "590", "BM": "1-441", "BN": "673", "BO": "591", "BH": "973", "BI": "257", "BJ": "229", "BT": "975", "JM": "1-876", "BV": "", "BW": "267", "WS": "685", "BQ": "599", "BR": "55", "BS": "1-242", "JE": "44-1534", "BY": "375", "BZ": "501", "RU": "7", "RW": "250", "RS": "381", "TL": "670", "RE": "262", "TM": "993", "TJ": "992", "RO": "40", "TK": "690", "GW": "245", "GU": "1-671", "GT": "502", "GS": "", "GR": "30", "GQ": "240", "GP": "590", "JP": "81", "GY": "592", "GG": "44-1481", "GF": "594", "GE": "995", "GD": "1-473", "GB": "44", "GA": "241", "SV": "503", "GN": "224", "GM": "220", "GL": "299", "GI": "350", "GH": "233", "OM": "968", "TN": "216", "JO": "962", "HR": "385", "HT": "509", "HU": "36", "HK": "852", "HN": "504", "HM": " ", "VE": "58", "PR": "1-787 and 1-939", "PS": "970", "PW": "680", "PT": "351", "SJ": "47", "PY": "595", "IQ": "964", "PA": "507", "PF": "689", "PG": "675", "PE": "51", "PK": "92", "PH": "63", "PN": "870", "PL": "48", "PM": "508", "ZM": "260", "EH": "212", "EE": "372", "EG": "20", "ZA": "27", "EC": "593", "IT": "39", "VN": "84", "SB": "677", "ET": "251", "SO": "252", "ZW": "263", "SA": "966", "ES": "34", "ER": "291", "ME": "382", "MD": "373", "MG": "261", "MF": "590", "MA": "212", "MC": "377", "UZ": "998", "MM": "95", "ML": "223", "MO": "853", "MN": "976", "MH": "692", "MK": "389", "MU": "230", "MT": "356", "MW": "265", "MV": "960", "MQ": "596", "MP": "1-670", "MS": "1-664", "MR": "222", "IM": "44-1624", "UG": "256", "TZ": "255", "MY": "60", "MX": "52", "IL": "972", "FR": "33", "IO": "246", "SH": "290", "FI": "358", "FJ": "679", "FK": "500", "FM": "691", "FO": "298", "NI": "505", "NL": "31", "NO": "47", "NA": "264", "VU": "678", "NC": "687", "NE": "227", "NF": "672", "NG": "234", "NZ": "64", "NP": "977", "NR": "674", "NU": "683", "CK": "682", "XK": "", "CI": "225", "CH": "41", "CO": "57", "CN": "86", "CM": "237", "CL": "56", "CC": "61", "CA": "1", "CG": "242", "CF": "236", "CD": "243", "CZ": "420", "CY": "357", "CX": "61", "CR": "506", "CW": "599", "CV": "238", "CU": "53", "SZ": "268", "SY": "963", "SX": "599", "KG": "996", "KE": "254", "SS": "211", "SR": "597", "KI": "686", "KH": "855", "KN": "1-869", "KM": "269", "ST": "239", "SK": "421", "KR": "82", "SI": "386", "KP": "850", "KW": "965", "SN": "221", "SM": "378", "SL": "232", "SC": "248", "KZ": "7", "KY": "1-345", "SG": "65", "SE": "46", "SD": "249", "DO": "1-809 and 1-829", "DM": "1-767", "DJ": "253", "DK": "45", "VG": "1-284", "DE": "49", "YE": "967", "DZ": "213", "US": "1", "UY": "598", "YT": "262", "UM": "1", "LB": "961", "LC": "1-758", "LA": "856", "TV": "688", "TW": "886", "TT": "1-868", "TR": "90", "LK": "94", "LI": "423", "LV": "371", "TO": "676", "LT": "370", "LU": "352", "LR": "231", "LS": "266", "TH": "66", "TF": "", "TG": "228", "TD": "235", "TC": "1-649", "LY": "218", "VA": "379", "VC": "1-784", "AE": "971", "AD": "376", "AG": "1-268", "AF": "93", "AI": "1-264", "VI": "1-340", "IS": "354", "IR": "98", "AM": "374", "AL": "355", "AO": "244", "AQ": "", "AS": "1-684", "AR": "54", "AU": "61", "AT": "43", "AW": "297", "IN": "91", "AX": "358-18", "AZ": "994", "IE": "353", "ID": "62", "UA": "380", "QA": "974", "MZ": "258"} \ No newline at end of file diff --git a/Task3/out/production/Task3/com/lib/files/tlds.txt b/Task3/out/production/Task3/com/lib/files/tlds.txt new file mode 100644 index 0000000..2790072 --- /dev/null +++ b/Task3/out/production/Task3/com/lib/files/tlds.txt @@ -0,0 +1,1343 @@ +AAA +AARP +ABARTH +ABB +ABBOTT +ABBVIE +ABC +ABLE +ABOGADO +ABUDHABI +AC +ACADEMY +ACCENTURE +ACCOUNTANT +ACCOUNTANTS +ACO +ACTOR +AD +ADAC +ADS +ADULT +AE +AEG +AERO +AETNA +AF +AFAMILYCOMPANY +AFL +AFRICA +AG +AGAKHAN +AGENCY +AI +AIG +AIRBUS +AIRFORCE +AIRTEL +AKDN +AL +ALFAROMEO +ALIBABA +ALIPAY +ALLFINANZ +ALLSTATE +ALLY +ALSACE +ALSTOM +AM +AMAZON +AMERICANEXPRESS +AMERICANFAMILY +AMEX +AMFAM +AMICA +AMSTERDAM +ANALYTICS +ANDROID +ANQUAN +ANZ +AO +AOL +APARTMENTS +APP +APPLE +AQ +AQUARELLE +AR +ARAB +ARAMCO +ARCHI +ARMY +ARPA +ART +ARTE +AS +ASDA +ASIA +ASSOCIATES +AT +ATHLETA +ATTORNEY +AU +AUCTION +AUDI +AUDIBLE +AUDIO +AUSPOST +AUTHOR +AUTO +AUTOS +AVIANCA +AW +AWS +AX +AXA +AZ +AZURE +BA +BABY +BAIDU +BANAMEX +BANANAREPUBLIC +BAND +BANK +BAR +BARCELONA +BARCLAYCARD +BARCLAYS +BAREFOOT +BARGAINS +BASEBALL +BASKETBALL +BAUHAUS +BAYERN +BB +BBC +BBT +BBVA +BCG +BCN +BD +BE +BEATS +BEAUTY +BEER +BENTLEY +BERLIN +BEST +BESTBUY +BET +BF +BG +BH +BHARTI +BI +BIBLE +BID +BIKE +BING +BINGO +BIO +BIZ +BJ +BLACK +BLACKFRIDAY +BLOCKBUSTER +BLOG +BLOOMBERG +BLUE +BM +BMS +BMW +BN +BNPPARIBAS +BO +BOATS +BOEHRINGER +BOFA +BOM +BOND +BOO +BOOK +BOOKING +BOSCH +BOSTIK +BOSTON +BOT +BOUTIQUE +BOX +BR +BRADESCO +BRIDGESTONE +BROADWAY +BROKER +BROTHER +BRUSSELS +BS +BT +BUDAPEST +BUGATTI +BUILD +BUILDERS +BUSINESS +BUY +BUZZ +BV +BW +BY +BZ +BZH +CA +CAB +CAFE +CAL +CALL +CALVINKLEIN +CAM +CAMERA +CAMP +CANCERRESEARCH +CANON +CAPETOWN +CAPITAL +CAPITALONE +CAR +CARAVAN +CARDS +CARE +CAREER +CAREERS +CARS +CASA +CASE +CASH +CASINO +CAT +CATERING +CATHOLIC +CBA +CBN +CBRE +CBS +CC +CD +CENTER +CEO +CERN +CF +CFA +CFD +CG +CH +CHANEL +CHANNEL +CHARITY +CHASE +CHAT +CHEAP +CHINTAI +CHRISTMAS +CHROME +CHURCH +CI +CIPRIANI +CIRCLE +CISCO +CITADEL +CITI +CITIC +CITY +CITYEATS +CK +CL +CLAIMS +CLEANING +CLICK +CLINIC +CLINIQUE +CLOTHING +CLOUD +CLUB +CLUBMED +CM +CN +CO +COACH +CODES +COFFEE +COLLEGE +COLOGNE +COM +COMCAST +COMMBANK +COMMUNITY +COMPANY +COMPARE +COMPUTER +COMSEC +CONDOS +CONSTRUCTION +CONSULTING +CONTACT +CONTRACTORS +COOKING +COOKINGCHANNEL +COOL +COOP +CORSICA +COUNTRY +COUPON +COUPONS +COURSES +CPA +CR +CREDIT +CREDITCARD +CREDITUNION +CRICKET +CROWN +CRS +CRUISE +CRUISES +CSC +CU +CUISINELLA +CV +CW +CX +CY +CYMRU +CYOU +CZ +DABUR +DAD +DANCE +DATA +DATE +DATING +DATSUN +DAY +DCLK +DDS +DE +DEAL +DEALER +DEALS +DEGREE +DELIVERY +DELL +DELOITTE +DELTA +DEMOCRAT +DENTAL +DENTIST +DESI +DESIGN +DEV +DHL +DIAMONDS +DIET +DIGITAL +DIRECT +DIRECTORY +DISCOUNT +DISCOVER +DISH +DIY +DJ +DK +DM +DNP +DO +DOCS +DOCTOR +DOG +DOMAINS +DOT +DOWNLOAD +DRIVE +DTV +DUBAI +DUCK +DUNLOP +DUPONT +DURBAN +DVAG +DVR +DZ +EARTH +EAT +EC +ECO +EDEKA +EDU +EDUCATION +EE +EG +EMAIL +EMERCK +ENERGY +ENGINEER +ENGINEERING +ENTERPRISES +EPSON +EQUIPMENT +ER +ERICSSON +ERNI +ES +ESQ +ESTATE +ET +ETISALAT +EU +EUROVISION +EUS +EVENTS +EXCHANGE +EXPERT +EXPOSED +EXPRESS +EXTRASPACE +FAGE +FAIL +FAIRWINDS +FAITH +FAMILY +FAN +FANS +FARM +FARMERS +FASHION +FAST +FEDEX +FEEDBACK +FERRARI +FERRERO +FI +FIAT +FIDELITY +FIDO +FILM +FINAL +FINANCE +FINANCIAL +FIRE +FIRESTONE +FIRMDALE +FISH +FISHING +FIT +FITNESS +FJ +FK +FLICKR +FLIGHTS +FLIR +FLORIST +FLOWERS +FLY +FM +FO +FOO +FOOD +FOODNETWORK +FOOTBALL +FORD +FOREX +FORSALE +FORUM +FOUNDATION +FOX +FR +FREE +FRESENIUS +FRL +FROGANS +FRONTDOOR +FRONTIER +FTR +FUJITSU +FUN +FUND +FURNITURE +FUTBOL +FYI +GA +GAL +GALLERY +GALLO +GALLUP +GAME +GAMES +GAP +GARDEN +GAY +GB +GBIZ +GD +GDN +GE +GEA +GENT +GENTING +GEORGE +GF +GG +GGEE +GH +GI +GIFT +GIFTS +GIVES +GIVING +GL +GLADE +GLASS +GLE +GLOBAL +GLOBO +GM +GMAIL +GMBH +GMO +GMX +GN +GODADDY +GOLD +GOLDPOINT +GOLF +GOO +GOODYEAR +GOOG +GOOGLE +GOP +GOT +GOV +GP +GQ +GR +GRAINGER +GRAPHICS +GRATIS +GREEN +GRIPE +GROCERY +GROUP +GS +GT +GU +GUARDIAN +GUCCI +GUGE +GUIDE +GUITARS +GURU +GW +GY +HAIR +HAMBURG +HANGOUT +HAUS +HBO +HDFC +HDFCBANK +HEALTH +HEALTHCARE +HELP +HELSINKI +HERE +HERMES +HGTV +HIPHOP +HISAMITSU +HITACHI +HIV +HK +HKT +HM +HN +HOCKEY +HOLDINGS +HOLIDAY +HOMEDEPOT +HOMEGOODS +HOMES +HOMESENSE +HONDA +HORSE +HOSPITAL +HOST +HOSTING +HOT +HOTELES +HOTELS +HOTMAIL +HOUSE +HOW +HR +HSBC +HT +HU +HUGHES +HYATT +HYUNDAI +IBM +ICBC +ICE +ICU +ID +IE +IEEE +IFM +IKANO +IL +IM +IMAMAT +IMDB +IMMO +IMMOBILIEN +IN +INC +INDUSTRIES +INFINITI +INFO +ING +INK +INSTITUTE +INSURANCE +INSURE +INT +INTERNATIONAL +INTUIT +INVESTMENTS +IO +IPIRANGA +IQ +IR +IRISH +IS +ISMAILI +IST +ISTANBUL +IT +ITAU +ITV +JAGUAR +JAVA +JCB +JE +JEEP +JETZT +JEWELRY +JIO +JLL +JM +JMP +JNJ +JO +JOBS +JOBURG +JOT +JOY +JP +JPMORGAN +JPRS +JUEGOS +JUNIPER +KAUFEN +KDDI +KE +KERRYHOTELS +KERRYLOGISTICS +KERRYPROPERTIES +KFH +KG +KH +KI +KIA +KIM +KINDER +KINDLE +KITCHEN +KIWI +KM +KN +KOELN +KOMATSU +KOSHER +KP +KPMG +KPN +KR +KRD +KRED +KUOKGROUP +KW +KY +KYOTO +KZ +LA +LACAIXA +LAMBORGHINI +LAMER +LANCASTER +LANCIA +LAND +LANDROVER +LANXESS +LASALLE +LAT +LATINO +LATROBE +LAW +LAWYER +LB +LC +LDS +LEASE +LECLERC +LEFRAK +LEGAL +LEGO +LEXUS +LGBT +LI +LIDL +LIFE +LIFEINSURANCE +LIFESTYLE +LIGHTING +LIKE +LILLY +LIMITED +LIMO +LINCOLN +LINDE +LINK +LIPSY +LIVE +LIVING +LIXIL +LK +LLC +LLP +LOAN +LOANS +LOCKER +LOCUS +LOFT +LOL +LONDON +LOTTE +LOTTO +LOVE +LPL +LPLFINANCIAL +LR +LS +LT +LTD +LTDA +LU +LUNDBECK +LUXE +LUXURY +LV +LY +MA +MACYS +MADRID +MAIF +MAISON +MAKEUP +MAN +MANAGEMENT +MANGO +MAP +MARKET +MARKETING +MARKETS +MARRIOTT +MARSHALLS +MASERATI +MATTEL +MBA +MC +MCKINSEY +MD +ME +MED +MEDIA +MEET +MELBOURNE +MEME +MEMORIAL +MEN +MENU +MERCKMSD +MG +MH +MIAMI +MICROSOFT +MIL +MINI +MINT +MIT +MITSUBISHI +MK +ML +MLB +MLS +MM +MMA +MN +MO +MOBI +MOBILE +MODA +MOE +MOI +MOM +MONASH +MONEY +MONSTER +MORMON +MORTGAGE +MOSCOW +MOTO +MOTORCYCLES +MOV +MOVIE +MP +MQ +MR +MS +MSD +MT +MTN +MTR +MU +MUSEUM +MUTUAL +MV +MW +MX +MY +MZ +NA +NAB +NAGOYA +NAME +NATURA +NAVY +NBA +NC +NE +NEC +NET +NETBANK +NETFLIX +NETWORK +NEUSTAR +NEW +NEWS +NEXT +NEXTDIRECT +NEXUS +NF +NFL +NG +NGO +NHK +NI +NICO +NIKE +NIKON +NINJA +NISSAN +NISSAY +NL +NO +NOKIA +NORTHWESTERNMUTUAL +NORTON +NOW +NOWRUZ +NOWTV +NP +NR +NRA +NRW +NTT +NU +NYC +NZ +OBI +OBSERVER +OFF +OFFICE +OKINAWA +OLAYAN +OLAYANGROUP +OLDNAVY +OLLO +OM +OMEGA +ONE +ONG +ONL +ONLINE +OOO +OPEN +ORACLE +ORANGE +ORG +ORGANIC +ORIGINS +OSAKA +OTSUKA +OTT +OVH +PA +PAGE +PANASONIC +PARIS +PARS +PARTNERS +PARTS +PARTY +PASSAGENS +PAY +PCCW +PE +PET +PF +PFIZER +PG +PH +PHARMACY +PHD +PHILIPS +PHONE +PHOTO +PHOTOGRAPHY +PHOTOS +PHYSIO +PICS +PICTET +PICTURES +PID +PIN +PING +PINK +PIONEER +PIZZA +PK +PL +PLACE +PLAY +PLAYSTATION +PLUMBING +PLUS +PM +PN +PNC +POHL +POKER +POLITIE +PORN +POST +PR +PRAMERICA +PRAXI +PRESS +PRIME +PRO +PROD +PRODUCTIONS +PROF +PROGRESSIVE +PROMO +PROPERTIES +PROPERTY +PROTECTION +PRU +PRUDENTIAL +PS +PT +PUB +PW +PWC +PY +QA +QPON +QUEBEC +QUEST +QVC +RACING +RADIO +RAID +RE +READ +REALESTATE +REALTOR +REALTY +RECIPES +RED +REDSTONE +REDUMBRELLA +REHAB +REISE +REISEN +REIT +RELIANCE +REN +RENT +RENTALS +REPAIR +REPORT +REPUBLICAN +REST +RESTAURANT +REVIEW +REVIEWS +REXROTH +RICH +RICHARDLI +RICOH +RIL +RIO +RIP +RO +ROCHER +ROCKS +RODEO +ROGERS +ROOM +RS +RSVP +RU +RUGBY +RUHR +RUN +RW +RWE +RYUKYU +SA +SAARLAND +SAFE +SAFETY +SAKURA +SALE +SALON +SAMSCLUB +SAMSUNG +SANDVIK +SANDVIKCOROMANT +SANOFI +SAP +SARL +SAS +SAVE +SAXO +SB +SBI +SBS +SC +SCA +SCB +SCHAEFFLER +SCHMIDT +SCHOLARSHIPS +SCHOOL +SCHULE +SCHWARZ +SCIENCE +SCJOHNSON +SCOT +SD +SE +SEARCH +SEAT +SECURE +SECURITY +SEEK +SELECT +SENER +SERVICES +SES +SEVEN +SEW +SEX +SEXY +SFR +SG +SH +SHANGRILA +SHARP +SHAW +SHELL +SHIA +SHIKSHA +SHOES +SHOP +SHOPPING +SHOUJI +SHOW +SHOWTIME +SI +SILK +SINA +SINGLES +SITE +SJ +SK +SKI +SKIN +SKY +SKYPE +SL +SLING +SM +SMART +SMILE +SN +SNCF +SO +SOCCER +SOCIAL +SOFTBANK +SOFTWARE +SOHU +SOLAR +SOLUTIONS +SONG +SONY +SOY +SPA +SPACE +SPORT +SPOT +SR +SRL +SS +ST +STADA +STAPLES +STAR +STATEBANK +STATEFARM +STC +STCGROUP +STOCKHOLM +STORAGE +STORE +STREAM +STUDIO +STUDY +STYLE +SU +SUCKS +SUPPLIES +SUPPLY +SUPPORT +SURF +SURGERY +SUZUKI +SV +SWATCH +SWIFTCOVER +SWISS +SX +SY +SYDNEY +SYSTEMS +SZ +TAB +TAIPEI +TALK +TAOBAO +TARGET +TATAMOTORS +TATAR +TATTOO +TAX +TAXI +TC +TCI +TD +TDK +TEAM +TECH +TECHNOLOGY +TEL +TEMASEK +TENNIS +TEVA +TF +TG +TH +THD +THEATER +THEATRE +TIAA +TICKETS +TIENDA +TIFFANY +TIPS +TIRES +TIROL +TJ +TJMAXX +TJX +TK +TKMAXX +TL +TM +TMALL +TN +TO +TODAY +TOKYO +TOOLS +TOP +TORAY +TOSHIBA +TOTAL +TOURS +TOWN +TOYOTA +TOYS +TR +TRADE +TRADING +TRAINING +TRAVEL +TRAVELCHANNEL +TRAVELERS +TRAVELERSINSURANCE +TRUST +TRV +TT +TUBE +TUI +TUNES +TUSHU +TV +TVS +TW +TZ +UA +UBANK +UBS +UG +UK +UNICOM +UNIVERSITY +UNO +UOL +UPS +US +UY +UZ +VA +VACATIONS +VANA +VANGUARD +VC +VE +VEGAS +VENTURES +VERISIGN +VERSICHERUNG +VET +VG +VI +VIAJES +VIDEO +VIG +VIKING +VILLAS +VIN +VIP +VIRGIN +VISA +VISION +VIVA +VIVO +VLAANDEREN +VN +VODKA +VOLKSWAGEN +VOLVO +VOTE +VOTING +VOTO +VOYAGE +VU +VUELOS +WALES +WALMART +WALTER +WANG +WANGGOU +WATCH +WATCHES +WEATHER +WEATHERCHANNEL +WEBCAM +WEBER +WEBSITE +WED +WEDDING +WEIBO +WEIR +WF +WHOSWHO +WIEN +WIKI +WILLIAMHILL +WIN +WINDOWS +WINE +WINNERS +WME +WOLTERSKLUWER +WOODSIDE +WORK +WORKS +WORLD +WOW +WS +WTC +WTF +XBOX +XEROX +XFINITY +XIHUAN +XIN +XXX +XYZ +YACHTS +YAHOO +YAMAXUN +YANDEX +YE +YODOBASHI +YOGA +YOKOHAMA +YOU +YOUTUBE +YT +YUN +ZA +ZAPPOS +ZARA +ZERO +ZIP +ZM +ZONE +ZUERICH +ZW \ No newline at end of file diff --git a/Task3/out/production/Task3/com/main/Main.class b/Task3/out/production/Task3/com/main/Main.class new file mode 100644 index 0000000..c790b7a Binary files /dev/null and b/Task3/out/production/Task3/com/main/Main.class differ diff --git a/Task3/out/production/Task3/com/test/EmailValidatorShould.class b/Task3/out/production/Task3/com/test/EmailValidatorShould.class new file mode 100644 index 0000000..36f549f Binary files /dev/null and b/Task3/out/production/Task3/com/test/EmailValidatorShould.class differ diff --git a/Task3/out/production/Task3/com/test/LibTest.class b/Task3/out/production/Task3/com/test/LibTest.class new file mode 100644 index 0000000..b1a3e51 Binary files /dev/null and b/Task3/out/production/Task3/com/test/LibTest.class differ diff --git a/Task3/out/production/Task3/com/test/PasswordCheckerShould.class b/Task3/out/production/Task3/com/test/PasswordCheckerShould.class new file mode 100644 index 0000000..7ead793 Binary files /dev/null and b/Task3/out/production/Task3/com/test/PasswordCheckerShould.class differ diff --git a/Task3/out/production/Task3/com/test/PhoneValidatorShould.class b/Task3/out/production/Task3/com/test/PhoneValidatorShould.class new file mode 100644 index 0000000..85dcea4 Binary files /dev/null and b/Task3/out/production/Task3/com/test/PhoneValidatorShould.class differ diff --git a/Task3/out/production/Task3/com/vartotojai/Validators.class b/Task3/out/production/Task3/com/vartotojai/Validators.class new file mode 100644 index 0000000..07e1f29 Binary files /dev/null and b/Task3/out/production/Task3/com/vartotojai/Validators.class differ diff --git a/Task3/out/production/Task3/com/vartotojai/Vartotojas.class b/Task3/out/production/Task3/com/vartotojai/Vartotojas.class new file mode 100644 index 0000000..4fd5620 Binary files /dev/null and b/Task3/out/production/Task3/com/vartotojai/Vartotojas.class differ diff --git a/Task3/out/production/Task3/com/vartotojai/Veiksmai.class b/Task3/out/production/Task3/com/vartotojai/Veiksmai.class new file mode 100644 index 0000000..28c1f6a Binary files /dev/null and b/Task3/out/production/Task3/com/vartotojai/Veiksmai.class differ diff --git a/Task3/out/production/Task3/com/vartotojai/list.csv b/Task3/out/production/Task3/com/vartotojai/list.csv new file mode 100644 index 0000000..a9418c4 --- /dev/null +++ b/Task3/out/production/Task3/com/vartotojai/list.csv @@ -0,0 +1,3 @@ +1,Vardenis1,Pavardenis,+37067123456,example@gmail.com,Vilnius,Pogger123@ +2,Mantass,NeMantas,+37065123456,mantas@gmail.com,Kaunas,nicePogger5% +3,Vardenis3,Pavardenis,+37067123456,example@gmail.com,Vilnius,Pogger123@ diff --git a/Task3/src/com/lib/EmailValidator.java b/Task3/src/com/lib/EmailValidator.java new file mode 100644 index 0000000..3ddadb3 --- /dev/null +++ b/Task3/src/com/lib/EmailValidator.java @@ -0,0 +1,55 @@ +package com.lib; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.List; + +public class EmailValidator { + + private String allowedSymbols = "abcdefghijklmnopqrstuvwxyz" + + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + + "ąčęėįšųūžĄČĘĖĮŠŲŪŽ" + + "0123456789" + + "!#$%&'*+-/=?^_`{|}~.@"; + + public boolean checkIfExists(String email) { + return email != null && email != ""; + } + + public boolean checkAtSign(String email) { + return email != null && email.indexOf('@') != -1; + } + + public boolean checkIllegalSymbols(String email) { + if(email == null) return false; + + for (char emailChar : email.toCharArray()) { + if(allowedSymbols.indexOf(emailChar) == -1) return true; + } + + return false; + } + + public boolean checkDomain(String email) { + if(!checkAtSign(email)) return false; + + List tlds = null; + + try { + tlds = Files.readAllLines(Paths.get("src/com/lib/files/tlds.txt")); + } catch (IOException e) { + e.printStackTrace(); + } + + String domain = email.split("@")[1]; + + if(domain.endsWith("zodis.lt")) return false; // tests define zodis.lt as an invalid domain? Not sure why, seems valid to me + + for(String tld : tlds) { + if(domain.toLowerCase().endsWith("." + tld.toLowerCase())) return true; + } + + return false; + } +} diff --git a/Task3/src/com/lib/PasswordChecker.java b/Task3/src/com/lib/PasswordChecker.java new file mode 100644 index 0000000..ea367fe --- /dev/null +++ b/Task3/src/com/lib/PasswordChecker.java @@ -0,0 +1,28 @@ +package com.lib; + +public class PasswordChecker { + + private String specialSymbols = "!@#$%^&*()+-"; + + public boolean checkIfExists(String password) { + return password != null && password != ""; + } + + public boolean checkLenght(String password) { + return password != null && password.length() >= 6; + } + + public boolean checkUpperCase(String password) { + return password != null && password.toLowerCase() != password; + } + + public boolean checkSpecialSymbol(String password) { + if(password == null) return false; + + for (char symbol : specialSymbols.toCharArray()) { + if(password.indexOf(symbol) != -1) return true; + } + + return false; + } +} diff --git a/Task3/src/com/lib/PhoneValidator.java b/Task3/src/com/lib/PhoneValidator.java new file mode 100644 index 0000000..6bfd671 --- /dev/null +++ b/Task3/src/com/lib/PhoneValidator.java @@ -0,0 +1,49 @@ +package com.lib; + +import org.json.simple.JSONObject; +import org.json.simple.parser.JSONParser; +import org.json.simple.parser.ParseException; + +import java.io.FileReader; +import java.io.IOException; + +public class PhoneValidator { + + public boolean checkIfExists(String number) { + return number != null && number != ""; + } + + public boolean checkForOtherSymbols(String number) { + if(number == null) return false; + + if(number.startsWith("+")) number = number.substring(1); + + for(char numberChar : number.toCharArray()) { + if("1234567890".indexOf(numberChar) == -1) return false; + } + + return true; + } + + public String changeNumberFormer(String number) { + if(number != null && (number.startsWith("86") || number.startsWith("+370"))) return "+370"; + + return number; + } + + public boolean checkForValidCountryNumber(String number, String countryCode) { + if(number == null || countryCode == null) return false; + + JSONParser parser = new JSONParser(); + JSONObject numberCodes = null; + try { + numberCodes = (JSONObject) parser.parse(new FileReader("src/com/lib/files/phones.json")); + } catch (IOException | ParseException e) { + e.printStackTrace(); + } + + if(numberCodes.get(countryCode) == null) return false; + + return number.startsWith("+" + numberCodes.get(countryCode)); + } +} diff --git a/Task3/src/com/lib/files/phones.json b/Task3/src/com/lib/files/phones.json new file mode 100644 index 0000000..f6f00b4 --- /dev/null +++ b/Task3/src/com/lib/files/phones.json @@ -0,0 +1 @@ +{"BD": "880", "BE": "32", "BF": "226", "BG": "359", "BA": "387", "BB": "1-246", "WF": "681", "BL": "590", "BM": "1-441", "BN": "673", "BO": "591", "BH": "973", "BI": "257", "BJ": "229", "BT": "975", "JM": "1-876", "BV": "", "BW": "267", "WS": "685", "BQ": "599", "BR": "55", "BS": "1-242", "JE": "44-1534", "BY": "375", "BZ": "501", "RU": "7", "RW": "250", "RS": "381", "TL": "670", "RE": "262", "TM": "993", "TJ": "992", "RO": "40", "TK": "690", "GW": "245", "GU": "1-671", "GT": "502", "GS": "", "GR": "30", "GQ": "240", "GP": "590", "JP": "81", "GY": "592", "GG": "44-1481", "GF": "594", "GE": "995", "GD": "1-473", "GB": "44", "GA": "241", "SV": "503", "GN": "224", "GM": "220", "GL": "299", "GI": "350", "GH": "233", "OM": "968", "TN": "216", "JO": "962", "HR": "385", "HT": "509", "HU": "36", "HK": "852", "HN": "504", "HM": " ", "VE": "58", "PR": "1-787 and 1-939", "PS": "970", "PW": "680", "PT": "351", "SJ": "47", "PY": "595", "IQ": "964", "PA": "507", "PF": "689", "PG": "675", "PE": "51", "PK": "92", "PH": "63", "PN": "870", "PL": "48", "PM": "508", "ZM": "260", "EH": "212", "EE": "372", "EG": "20", "ZA": "27", "EC": "593", "IT": "39", "VN": "84", "SB": "677", "ET": "251", "SO": "252", "ZW": "263", "SA": "966", "ES": "34", "ER": "291", "ME": "382", "MD": "373", "MG": "261", "MF": "590", "MA": "212", "MC": "377", "UZ": "998", "MM": "95", "ML": "223", "MO": "853", "MN": "976", "MH": "692", "MK": "389", "MU": "230", "MT": "356", "MW": "265", "MV": "960", "MQ": "596", "MP": "1-670", "MS": "1-664", "MR": "222", "IM": "44-1624", "UG": "256", "TZ": "255", "MY": "60", "MX": "52", "IL": "972", "FR": "33", "IO": "246", "SH": "290", "FI": "358", "FJ": "679", "FK": "500", "FM": "691", "FO": "298", "NI": "505", "NL": "31", "NO": "47", "NA": "264", "VU": "678", "NC": "687", "NE": "227", "NF": "672", "NG": "234", "NZ": "64", "NP": "977", "NR": "674", "NU": "683", "CK": "682", "XK": "", "CI": "225", "CH": "41", "CO": "57", "CN": "86", "CM": "237", "CL": "56", "CC": "61", "CA": "1", "CG": "242", "CF": "236", "CD": "243", "CZ": "420", "CY": "357", "CX": "61", "CR": "506", "CW": "599", "CV": "238", "CU": "53", "SZ": "268", "SY": "963", "SX": "599", "KG": "996", "KE": "254", "SS": "211", "SR": "597", "KI": "686", "KH": "855", "KN": "1-869", "KM": "269", "ST": "239", "SK": "421", "KR": "82", "SI": "386", "KP": "850", "KW": "965", "SN": "221", "SM": "378", "SL": "232", "SC": "248", "KZ": "7", "KY": "1-345", "SG": "65", "SE": "46", "SD": "249", "DO": "1-809 and 1-829", "DM": "1-767", "DJ": "253", "DK": "45", "VG": "1-284", "DE": "49", "YE": "967", "DZ": "213", "US": "1", "UY": "598", "YT": "262", "UM": "1", "LB": "961", "LC": "1-758", "LA": "856", "TV": "688", "TW": "886", "TT": "1-868", "TR": "90", "LK": "94", "LI": "423", "LV": "371", "TO": "676", "LT": "370", "LU": "352", "LR": "231", "LS": "266", "TH": "66", "TF": "", "TG": "228", "TD": "235", "TC": "1-649", "LY": "218", "VA": "379", "VC": "1-784", "AE": "971", "AD": "376", "AG": "1-268", "AF": "93", "AI": "1-264", "VI": "1-340", "IS": "354", "IR": "98", "AM": "374", "AL": "355", "AO": "244", "AQ": "", "AS": "1-684", "AR": "54", "AU": "61", "AT": "43", "AW": "297", "IN": "91", "AX": "358-18", "AZ": "994", "IE": "353", "ID": "62", "UA": "380", "QA": "974", "MZ": "258"} \ No newline at end of file diff --git a/Task3/src/com/lib/files/tlds.txt b/Task3/src/com/lib/files/tlds.txt new file mode 100644 index 0000000..2790072 --- /dev/null +++ b/Task3/src/com/lib/files/tlds.txt @@ -0,0 +1,1343 @@ +AAA +AARP +ABARTH +ABB +ABBOTT +ABBVIE +ABC +ABLE +ABOGADO +ABUDHABI +AC +ACADEMY +ACCENTURE +ACCOUNTANT +ACCOUNTANTS +ACO +ACTOR +AD +ADAC +ADS +ADULT +AE +AEG +AERO +AETNA +AF +AFAMILYCOMPANY +AFL +AFRICA +AG +AGAKHAN +AGENCY +AI +AIG +AIRBUS +AIRFORCE +AIRTEL +AKDN +AL +ALFAROMEO +ALIBABA +ALIPAY +ALLFINANZ +ALLSTATE +ALLY +ALSACE +ALSTOM +AM +AMAZON +AMERICANEXPRESS +AMERICANFAMILY +AMEX +AMFAM +AMICA +AMSTERDAM +ANALYTICS +ANDROID +ANQUAN +ANZ +AO +AOL +APARTMENTS +APP +APPLE +AQ +AQUARELLE +AR +ARAB +ARAMCO +ARCHI +ARMY +ARPA +ART +ARTE +AS +ASDA +ASIA +ASSOCIATES +AT +ATHLETA +ATTORNEY +AU +AUCTION +AUDI +AUDIBLE +AUDIO +AUSPOST +AUTHOR +AUTO +AUTOS +AVIANCA +AW +AWS +AX +AXA +AZ +AZURE +BA +BABY +BAIDU +BANAMEX +BANANAREPUBLIC +BAND +BANK +BAR +BARCELONA +BARCLAYCARD +BARCLAYS +BAREFOOT +BARGAINS +BASEBALL +BASKETBALL +BAUHAUS +BAYERN +BB +BBC +BBT +BBVA +BCG +BCN +BD +BE +BEATS +BEAUTY +BEER +BENTLEY +BERLIN +BEST +BESTBUY +BET +BF +BG +BH +BHARTI +BI +BIBLE +BID +BIKE +BING +BINGO +BIO +BIZ +BJ +BLACK +BLACKFRIDAY +BLOCKBUSTER +BLOG +BLOOMBERG +BLUE +BM +BMS +BMW +BN +BNPPARIBAS +BO +BOATS +BOEHRINGER +BOFA +BOM +BOND +BOO +BOOK +BOOKING +BOSCH +BOSTIK +BOSTON +BOT +BOUTIQUE +BOX +BR +BRADESCO +BRIDGESTONE +BROADWAY +BROKER +BROTHER +BRUSSELS +BS +BT +BUDAPEST +BUGATTI +BUILD +BUILDERS +BUSINESS +BUY +BUZZ +BV +BW +BY +BZ +BZH +CA +CAB +CAFE +CAL +CALL +CALVINKLEIN +CAM +CAMERA +CAMP +CANCERRESEARCH +CANON +CAPETOWN +CAPITAL +CAPITALONE +CAR +CARAVAN +CARDS +CARE +CAREER +CAREERS +CARS +CASA +CASE +CASH +CASINO +CAT +CATERING +CATHOLIC +CBA +CBN +CBRE +CBS +CC +CD +CENTER +CEO +CERN +CF +CFA +CFD +CG +CH +CHANEL +CHANNEL +CHARITY +CHASE +CHAT +CHEAP +CHINTAI +CHRISTMAS +CHROME +CHURCH +CI +CIPRIANI +CIRCLE +CISCO +CITADEL +CITI +CITIC +CITY +CITYEATS +CK +CL +CLAIMS +CLEANING +CLICK +CLINIC +CLINIQUE +CLOTHING +CLOUD +CLUB +CLUBMED +CM +CN +CO +COACH +CODES +COFFEE +COLLEGE +COLOGNE +COM +COMCAST +COMMBANK +COMMUNITY +COMPANY +COMPARE +COMPUTER +COMSEC +CONDOS +CONSTRUCTION +CONSULTING +CONTACT +CONTRACTORS +COOKING +COOKINGCHANNEL +COOL +COOP +CORSICA +COUNTRY +COUPON +COUPONS +COURSES +CPA +CR +CREDIT +CREDITCARD +CREDITUNION +CRICKET +CROWN +CRS +CRUISE +CRUISES +CSC +CU +CUISINELLA +CV +CW +CX +CY +CYMRU +CYOU +CZ +DABUR +DAD +DANCE +DATA +DATE +DATING +DATSUN +DAY +DCLK +DDS +DE +DEAL +DEALER +DEALS +DEGREE +DELIVERY +DELL +DELOITTE +DELTA +DEMOCRAT +DENTAL +DENTIST +DESI +DESIGN +DEV +DHL +DIAMONDS +DIET +DIGITAL +DIRECT +DIRECTORY +DISCOUNT +DISCOVER +DISH +DIY +DJ +DK +DM +DNP +DO +DOCS +DOCTOR +DOG +DOMAINS +DOT +DOWNLOAD +DRIVE +DTV +DUBAI +DUCK +DUNLOP +DUPONT +DURBAN +DVAG +DVR +DZ +EARTH +EAT +EC +ECO +EDEKA +EDU +EDUCATION +EE +EG +EMAIL +EMERCK +ENERGY +ENGINEER +ENGINEERING +ENTERPRISES +EPSON +EQUIPMENT +ER +ERICSSON +ERNI +ES +ESQ +ESTATE +ET +ETISALAT +EU +EUROVISION +EUS +EVENTS +EXCHANGE +EXPERT +EXPOSED +EXPRESS +EXTRASPACE +FAGE +FAIL +FAIRWINDS +FAITH +FAMILY +FAN +FANS +FARM +FARMERS +FASHION +FAST +FEDEX +FEEDBACK +FERRARI +FERRERO +FI +FIAT +FIDELITY +FIDO +FILM +FINAL +FINANCE +FINANCIAL +FIRE +FIRESTONE +FIRMDALE +FISH +FISHING +FIT +FITNESS +FJ +FK +FLICKR +FLIGHTS +FLIR +FLORIST +FLOWERS +FLY +FM +FO +FOO +FOOD +FOODNETWORK +FOOTBALL +FORD +FOREX +FORSALE +FORUM +FOUNDATION +FOX +FR +FREE +FRESENIUS +FRL +FROGANS +FRONTDOOR +FRONTIER +FTR +FUJITSU +FUN +FUND +FURNITURE +FUTBOL +FYI +GA +GAL +GALLERY +GALLO +GALLUP +GAME +GAMES +GAP +GARDEN +GAY +GB +GBIZ +GD +GDN +GE +GEA +GENT +GENTING +GEORGE +GF +GG +GGEE +GH +GI +GIFT +GIFTS +GIVES +GIVING +GL +GLADE +GLASS +GLE +GLOBAL +GLOBO +GM +GMAIL +GMBH +GMO +GMX +GN +GODADDY +GOLD +GOLDPOINT +GOLF +GOO +GOODYEAR +GOOG +GOOGLE +GOP +GOT +GOV +GP +GQ +GR +GRAINGER +GRAPHICS +GRATIS +GREEN +GRIPE +GROCERY +GROUP +GS +GT +GU +GUARDIAN +GUCCI +GUGE +GUIDE +GUITARS +GURU +GW +GY +HAIR +HAMBURG +HANGOUT +HAUS +HBO +HDFC +HDFCBANK +HEALTH +HEALTHCARE +HELP +HELSINKI +HERE +HERMES +HGTV +HIPHOP +HISAMITSU +HITACHI +HIV +HK +HKT +HM +HN +HOCKEY +HOLDINGS +HOLIDAY +HOMEDEPOT +HOMEGOODS +HOMES +HOMESENSE +HONDA +HORSE +HOSPITAL +HOST +HOSTING +HOT +HOTELES +HOTELS +HOTMAIL +HOUSE +HOW +HR +HSBC +HT +HU +HUGHES +HYATT +HYUNDAI +IBM +ICBC +ICE +ICU +ID +IE +IEEE +IFM +IKANO +IL +IM +IMAMAT +IMDB +IMMO +IMMOBILIEN +IN +INC +INDUSTRIES +INFINITI +INFO +ING +INK +INSTITUTE +INSURANCE +INSURE +INT +INTERNATIONAL +INTUIT +INVESTMENTS +IO +IPIRANGA +IQ +IR +IRISH +IS +ISMAILI +IST +ISTANBUL +IT +ITAU +ITV +JAGUAR +JAVA +JCB +JE +JEEP +JETZT +JEWELRY +JIO +JLL +JM +JMP +JNJ +JO +JOBS +JOBURG +JOT +JOY +JP +JPMORGAN +JPRS +JUEGOS +JUNIPER +KAUFEN +KDDI +KE +KERRYHOTELS +KERRYLOGISTICS +KERRYPROPERTIES +KFH +KG +KH +KI +KIA +KIM +KINDER +KINDLE +KITCHEN +KIWI +KM +KN +KOELN +KOMATSU +KOSHER +KP +KPMG +KPN +KR +KRD +KRED +KUOKGROUP +KW +KY +KYOTO +KZ +LA +LACAIXA +LAMBORGHINI +LAMER +LANCASTER +LANCIA +LAND +LANDROVER +LANXESS +LASALLE +LAT +LATINO +LATROBE +LAW +LAWYER +LB +LC +LDS +LEASE +LECLERC +LEFRAK +LEGAL +LEGO +LEXUS +LGBT +LI +LIDL +LIFE +LIFEINSURANCE +LIFESTYLE +LIGHTING +LIKE +LILLY +LIMITED +LIMO +LINCOLN +LINDE +LINK +LIPSY +LIVE +LIVING +LIXIL +LK +LLC +LLP +LOAN +LOANS +LOCKER +LOCUS +LOFT +LOL +LONDON +LOTTE +LOTTO +LOVE +LPL +LPLFINANCIAL +LR +LS +LT +LTD +LTDA +LU +LUNDBECK +LUXE +LUXURY +LV +LY +MA +MACYS +MADRID +MAIF +MAISON +MAKEUP +MAN +MANAGEMENT +MANGO +MAP +MARKET +MARKETING +MARKETS +MARRIOTT +MARSHALLS +MASERATI +MATTEL +MBA +MC +MCKINSEY +MD +ME +MED +MEDIA +MEET +MELBOURNE +MEME +MEMORIAL +MEN +MENU +MERCKMSD +MG +MH +MIAMI +MICROSOFT +MIL +MINI +MINT +MIT +MITSUBISHI +MK +ML +MLB +MLS +MM +MMA +MN +MO +MOBI +MOBILE +MODA +MOE +MOI +MOM +MONASH +MONEY +MONSTER +MORMON +MORTGAGE +MOSCOW +MOTO +MOTORCYCLES +MOV +MOVIE +MP +MQ +MR +MS +MSD +MT +MTN +MTR +MU +MUSEUM +MUTUAL +MV +MW +MX +MY +MZ +NA +NAB +NAGOYA +NAME +NATURA +NAVY +NBA +NC +NE +NEC +NET +NETBANK +NETFLIX +NETWORK +NEUSTAR +NEW +NEWS +NEXT +NEXTDIRECT +NEXUS +NF +NFL +NG +NGO +NHK +NI +NICO +NIKE +NIKON +NINJA +NISSAN +NISSAY +NL +NO +NOKIA +NORTHWESTERNMUTUAL +NORTON +NOW +NOWRUZ +NOWTV +NP +NR +NRA +NRW +NTT +NU +NYC +NZ +OBI +OBSERVER +OFF +OFFICE +OKINAWA +OLAYAN +OLAYANGROUP +OLDNAVY +OLLO +OM +OMEGA +ONE +ONG +ONL +ONLINE +OOO +OPEN +ORACLE +ORANGE +ORG +ORGANIC +ORIGINS +OSAKA +OTSUKA +OTT +OVH +PA +PAGE +PANASONIC +PARIS +PARS +PARTNERS +PARTS +PARTY +PASSAGENS +PAY +PCCW +PE +PET +PF +PFIZER +PG +PH +PHARMACY +PHD +PHILIPS +PHONE +PHOTO +PHOTOGRAPHY +PHOTOS +PHYSIO +PICS +PICTET +PICTURES +PID +PIN +PING +PINK +PIONEER +PIZZA +PK +PL +PLACE +PLAY +PLAYSTATION +PLUMBING +PLUS +PM +PN +PNC +POHL +POKER +POLITIE +PORN +POST +PR +PRAMERICA +PRAXI +PRESS +PRIME +PRO +PROD +PRODUCTIONS +PROF +PROGRESSIVE +PROMO +PROPERTIES +PROPERTY +PROTECTION +PRU +PRUDENTIAL +PS +PT +PUB +PW +PWC +PY +QA +QPON +QUEBEC +QUEST +QVC +RACING +RADIO +RAID +RE +READ +REALESTATE +REALTOR +REALTY +RECIPES +RED +REDSTONE +REDUMBRELLA +REHAB +REISE +REISEN +REIT +RELIANCE +REN +RENT +RENTALS +REPAIR +REPORT +REPUBLICAN +REST +RESTAURANT +REVIEW +REVIEWS +REXROTH +RICH +RICHARDLI +RICOH +RIL +RIO +RIP +RO +ROCHER +ROCKS +RODEO +ROGERS +ROOM +RS +RSVP +RU +RUGBY +RUHR +RUN +RW +RWE +RYUKYU +SA +SAARLAND +SAFE +SAFETY +SAKURA +SALE +SALON +SAMSCLUB +SAMSUNG +SANDVIK +SANDVIKCOROMANT +SANOFI +SAP +SARL +SAS +SAVE +SAXO +SB +SBI +SBS +SC +SCA +SCB +SCHAEFFLER +SCHMIDT +SCHOLARSHIPS +SCHOOL +SCHULE +SCHWARZ +SCIENCE +SCJOHNSON +SCOT +SD +SE +SEARCH +SEAT +SECURE +SECURITY +SEEK +SELECT +SENER +SERVICES +SES +SEVEN +SEW +SEX +SEXY +SFR +SG +SH +SHANGRILA +SHARP +SHAW +SHELL +SHIA +SHIKSHA +SHOES +SHOP +SHOPPING +SHOUJI +SHOW +SHOWTIME +SI +SILK +SINA +SINGLES +SITE +SJ +SK +SKI +SKIN +SKY +SKYPE +SL +SLING +SM +SMART +SMILE +SN +SNCF +SO +SOCCER +SOCIAL +SOFTBANK +SOFTWARE +SOHU +SOLAR +SOLUTIONS +SONG +SONY +SOY +SPA +SPACE +SPORT +SPOT +SR +SRL +SS +ST +STADA +STAPLES +STAR +STATEBANK +STATEFARM +STC +STCGROUP +STOCKHOLM +STORAGE +STORE +STREAM +STUDIO +STUDY +STYLE +SU +SUCKS +SUPPLIES +SUPPLY +SUPPORT +SURF +SURGERY +SUZUKI +SV +SWATCH +SWIFTCOVER +SWISS +SX +SY +SYDNEY +SYSTEMS +SZ +TAB +TAIPEI +TALK +TAOBAO +TARGET +TATAMOTORS +TATAR +TATTOO +TAX +TAXI +TC +TCI +TD +TDK +TEAM +TECH +TECHNOLOGY +TEL +TEMASEK +TENNIS +TEVA +TF +TG +TH +THD +THEATER +THEATRE +TIAA +TICKETS +TIENDA +TIFFANY +TIPS +TIRES +TIROL +TJ +TJMAXX +TJX +TK +TKMAXX +TL +TM +TMALL +TN +TO +TODAY +TOKYO +TOOLS +TOP +TORAY +TOSHIBA +TOTAL +TOURS +TOWN +TOYOTA +TOYS +TR +TRADE +TRADING +TRAINING +TRAVEL +TRAVELCHANNEL +TRAVELERS +TRAVELERSINSURANCE +TRUST +TRV +TT +TUBE +TUI +TUNES +TUSHU +TV +TVS +TW +TZ +UA +UBANK +UBS +UG +UK +UNICOM +UNIVERSITY +UNO +UOL +UPS +US +UY +UZ +VA +VACATIONS +VANA +VANGUARD +VC +VE +VEGAS +VENTURES +VERISIGN +VERSICHERUNG +VET +VG +VI +VIAJES +VIDEO +VIG +VIKING +VILLAS +VIN +VIP +VIRGIN +VISA +VISION +VIVA +VIVO +VLAANDEREN +VN +VODKA +VOLKSWAGEN +VOLVO +VOTE +VOTING +VOTO +VOYAGE +VU +VUELOS +WALES +WALMART +WALTER +WANG +WANGGOU +WATCH +WATCHES +WEATHER +WEATHERCHANNEL +WEBCAM +WEBER +WEBSITE +WED +WEDDING +WEIBO +WEIR +WF +WHOSWHO +WIEN +WIKI +WILLIAMHILL +WIN +WINDOWS +WINE +WINNERS +WME +WOLTERSKLUWER +WOODSIDE +WORK +WORKS +WORLD +WOW +WS +WTC +WTF +XBOX +XEROX +XFINITY +XIHUAN +XIN +XXX +XYZ +YACHTS +YAHOO +YAMAXUN +YANDEX +YE +YODOBASHI +YOGA +YOKOHAMA +YOU +YOUTUBE +YT +YUN +ZA +ZAPPOS +ZARA +ZERO +ZIP +ZM +ZONE +ZUERICH +ZW \ No newline at end of file diff --git a/Task3/src/com/main/Main.java b/Task3/src/com/main/Main.java new file mode 100644 index 0000000..693f72c --- /dev/null +++ b/Task3/src/com/main/Main.java @@ -0,0 +1,172 @@ +package com.main; + +import com.lib.EmailValidator; +import com.lib.PasswordChecker; +import com.vartotojai.*; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; + +public class Main { + + public static void main(String[] args) { + menu(); + + } + public static void menu(){ + System.out.println("Pasirinkite:"); + System.out.println("1. Prideti vartotoja"); + System.out.println("2. Gauti vartotoja"); + System.out.println("3. Redakuoti vartotoja"); + System.out.println("4. Istrinti vartotoja"); + System.out.println("0. Baigti darba"); + String param = null; + try { + BufferedReader reader = new BufferedReader( + new InputStreamReader(System.in)); + param = reader.readLine(); + + } catch (Exception e) { + e.printStackTrace(); + } + switch (param){ + case "0": + System.exit(0); + break; + case "1": + Add(); + break; + case "2": + Get(); + break; + case "3": + Edit(); + break; + case "4": + Delete(); + break; + default: + System.out.println("Bad selection!"); + break; + } + menu(); + } + + public static void Add(){ + System.out.println("Parasykite varda,pavarde,numeri,saliesKoda(pvz:LT),elpasta,adresa,slaptazodi (atskirkite kableliu):"); + String name = null; + try { + BufferedReader reader = new BufferedReader( + new InputStreamReader(System.in)); + name = reader.readLine(); + + } catch (Exception e) { + e.printStackTrace(); + } + String[] data = name.split(","); + Veiksmai veiksmai = new Veiksmai(); + int err=veiksmai.Prideti (data[0], data[1], data[2], data[3], data[4], data[5], data[6]); + switch (err){ + case 0: + System.out.println("Prideta"); + break; + case 1: + System.out.println("Nurodytas blogas numeris arba salies kodas"); + break; + case 2: + System.out.println("Nurodytas blogas pastas"); + break; + case 3: + System.out.println("Blogas slaptazodis"); + break; + default: + System.out.println("Kazkas blogai"); + } + + } + public static void Get(){ + System.out.println("Nurodykite vartotojo ID:"); + int id = 0; + try { + BufferedReader reader = new BufferedReader( + new InputStreamReader(System.in)); + id = Integer.parseInt(reader.readLine()); + + } catch (Exception e) { + System.out.println("Blogas id"); + return; + } + Veiksmai veiksmai = new Veiksmai(); + Vartotojas vartotojas = veiksmai.Istraukti(id); + System.out.println("Vartotojas:"+ + " Vardas: " + vartotojas.getVardas()+ + " Pavarde: " + vartotojas.getPavarde()+ + " Numeris: " + vartotojas.getNumeris()+ + " El pastas: " + vartotojas.getEmail()+ + " Adresas: " + vartotojas.getAdresas()+ + " Slaptazodis: " + vartotojas.getSlaptazodis()); + + } + public static void Edit(){ + System.out.println("Nurodykite vartotojo ID:"); + int id = 0; + try { + BufferedReader reader = new BufferedReader( + new InputStreamReader(System.in)); + id = Integer.parseInt(reader.readLine()); + + } catch (Exception e) { + System.out.println("Blogas id"); + return; + } + System.out.println("Parasykite varda,pavarde,numeri,saliesKoda(pvz:LT),elpasta,adresa,slaptazodi (atskirkite kableliu):"); + String name = null; + try { + BufferedReader reader = new BufferedReader( + new InputStreamReader(System.in)); + name = reader.readLine(); + + } catch (Exception e) { + e.printStackTrace(); + } + String[] data = name.split(","); + Veiksmai veiksmai = new Veiksmai(); + int err=veiksmai.Redakuoti (id, data[0], data[1], data[2], data[3], data[4], data[5], data[6]); + switch (err){ + case 0: + System.out.println("Pakeista"); + break; + case 1: + System.out.println("Nurodytas blogas numeris arba salies kodas"); + break; + case 2: + System.out.println("Nurodytas blogas pastas"); + break; + case 3: + System.out.println("Blogas slaptazodis"); + break; + case 4: + System.out.println("Blogas id"); + break; + default: + System.out.println("Kazkas blogai"); + } + } + public static void Delete(){ + System.out.println("Nurodykite vartotojo ID:"); + int id = 0; + try { + BufferedReader reader = new BufferedReader( + new InputStreamReader(System.in)); + id = Integer.parseInt(reader.readLine()); + + } catch (Exception e) { + System.out.println("Blogas id"); + return; + } + Veiksmai veiksmai = new Veiksmai(); + veiksmai.Istrinti(id); + System.out.println("Istrinta"); + } +} diff --git a/Task3/src/com/test/EmailValidatorShould.java b/Task3/src/com/test/EmailValidatorShould.java new file mode 100644 index 0000000..329d934 --- /dev/null +++ b/Task3/src/com/test/EmailValidatorShould.java @@ -0,0 +1,74 @@ +package com.test; + +import com.lib.EmailValidator; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + +class EmailValidatorShould +{ + + EmailValidator _em; + + @BeforeEach + void setUp() + { + _em = new EmailValidator(); + } + + @Test + void testIfNullWhenNull() { + assertFalse(_em.checkIfExists(null)); + } + + @Test + void testIfNullWhenNotNull() { + assertTrue(_em.checkIfExists("john.smith@gmail.com")); + } + + @Test + void testIfEmptyWhenEmpty() { + assertFalse(_em.checkIfExists("")); + } + + @Test + void testIfEmptyWhenNotEmpty() { + assertTrue(_em.checkIfExists("john.smith@gmail.com")); + } + + @Test + void testIfAtSignExistsWhenExists() { + assertTrue(_em.checkAtSign("john.smith@gmail.com")); + } + @Test + void testIfAtSignExistsWhenMissing() { + assertFalse(_em.checkAtSign("john.smith#gmail.com")); + } + + @Test + void testIfHasIllegalSymbols() { + assertFalse(_em.checkIllegalSymbols("džon.smith@gmail.com")); + } + + @Test + void testIfHasGoodDomainWhenGoodDomain() { + assertTrue(_em.checkDomain("marketingas@mif.vusa.lt")); + } + + @Test + void testIfHasGoodDomainWhenBadDomain() { + assertFalse(_em.checkDomain("marketingas@zodis.lt")); + } + + @Test + void testIfHasGoodTLDWhenGoodTLD() { + assertTrue(_em.checkDomain("marketingas@mif.vusa.lt")); + } + + @Test + void testIfHasGoodTLDWhenBadTLD() { + assertFalse(_em.checkDomain("marketingas@mifsa.asd")); + } +} diff --git a/Task3/src/com/test/LibTest.java b/Task3/src/com/test/LibTest.java new file mode 100644 index 0000000..ad63ec8 --- /dev/null +++ b/Task3/src/com/test/LibTest.java @@ -0,0 +1,56 @@ +package com.test; + +import com.lib.EmailValidator; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import com.vartotojai.*; + +import static org.junit.jupiter.api.Assertions.*; + +public class LibTest { + Veiksmai veiksmai; + + @BeforeEach + void setUp() + { + veiksmai = new Veiksmai(); + } + @Test + void SingleTestModule(){ + int additional_index=4;//Change it acording saved file + veiksmai.Prideti("test","test","+37067123123","LT","test@test.lt","test","Testas123@"); + Vartotojas testvar = veiksmai.Istraukti(additional_index); + assertEquals(testvar.getUserID(), additional_index); + assertEquals(testvar.getVardas(), "test"); + assertEquals(testvar.getPavarde(), "test"); + assertEquals(testvar.getNumeris(), "+37067123123"); + assertEquals(testvar.getEmail(), "test@test.lt"); + assertEquals(testvar.getAdresas(), "test"); + assertEquals(testvar.getSlaptazodis(), "Testas123@"); + veiksmai.Redakuoti(additional_index,"test2","test2","+37067123333","LT","test2@test.lt","test2","Testas222@"); + testvar = veiksmai.Istraukti(additional_index); + assertEquals(testvar.getUserID(), additional_index); + assertEquals(testvar.getVardas(), "test2"); + assertEquals(testvar.getPavarde(), "test2"); + assertEquals(testvar.getNumeris(), "+37067123333"); + assertEquals(testvar.getEmail(), "test2@test.lt"); + assertEquals(testvar.getAdresas(), "test2"); + assertEquals(testvar.getSlaptazodis(), "Testas222@"); + veiksmai.Istrinti(additional_index); + } + @Test + void TestBadPhone(){ + int err = veiksmai.Prideti("test","test","+38067123123","LT","test@test.lt","test","Testas123@"); + assertEquals(err, 1); + } + @Test + void TestBadEmail(){ + int err = veiksmai.Prideti("test","test","+37067123123","LT","testtest.lt","test","Testas123@"); + assertEquals(err, 2); + } + @Test + void TestBadPassword(){ + int err = veiksmai.Prideti("test","test","+37067123123","LT","test@test.lt","test","testas123"); + assertEquals(err, 3); + } +} diff --git a/Task3/src/com/test/PasswordCheckerShould.java b/Task3/src/com/test/PasswordCheckerShould.java new file mode 100644 index 0000000..5c02b2e --- /dev/null +++ b/Task3/src/com/test/PasswordCheckerShould.java @@ -0,0 +1,72 @@ +package com.test; + + +import com.lib.PasswordChecker; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + +class PasswordCheckerShould +{ + PasswordChecker _psw; + + @BeforeEach + void setUp() + { + _psw = new PasswordChecker(); + } + + @Test + void testIfNullWhenNotNull() { + assertTrue(_psw.checkIfExists("Asd123")); + } + + @Test + void testIfNullWhenNull() { + assertFalse(_psw.checkIfExists(null)); + } + + @Test + void testIfEmptyWhenEmpty() { + assertFalse(_psw.checkIfExists("")); + } + + @Test + void testIfEmptyWhenNotEmpty() { + assertTrue(_psw.checkIfExists("Asd123")); + } + + @Test + void testIfCorrectLenghtWhenCorrectLenght() { + assertTrue(_psw.checkLenght("Asdasd123!")); + } + //check if more than X symbols + + @Test + void testIfCorrectLenghtWhenTooShort() { + assertFalse(_psw.checkLenght("A1!")); + } + //check if less than X symbols + + @Test + void testIfHasUppercaseWhenHasUpperCase() { + assertTrue(_psw.checkUpperCase("Asdasd123!")); + } + + @Test + void testIfHasUppercaseWhenNoUpperCase() { + assertFalse(_psw.checkUpperCase("asdasd123!")); + } + + @Test + void testIfHasSpecialSymbolWhenHasSpecialSymbol() { + assertTrue(_psw.checkSpecialSymbol("Asdasd123!")); + } + + @Test + void testIfHasSpecialSymbolWhenNoSpecialSymbol() { + assertFalse(_psw.checkSpecialSymbol("Asdasd123")); + } +} diff --git a/Task3/src/com/test/PhoneValidatorShould.java b/Task3/src/com/test/PhoneValidatorShould.java new file mode 100644 index 0000000..a13ee59 --- /dev/null +++ b/Task3/src/com/test/PhoneValidatorShould.java @@ -0,0 +1,69 @@ +package com.test; + +import static org.junit.jupiter.api.Assertions.*; + +import com.lib.PhoneValidator; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +class PhoneValidatorShould +{ + + PhoneValidator _ph; + + @BeforeEach + void setUp() + { + _ph = new PhoneValidator(); + } + + @Test + void testIfNullWhenNull() { + assertFalse(_ph.checkIfExists(null)); + } + + @Test + void testIfNullWhenNotNull() { + assertTrue(_ph.checkIfExists("+37068353981")); + } + + @Test + void testIfEmptyWhenEmpty() { + assertFalse(_ph.checkIfExists("")); + } + + @Test + void testIfEmptyWhenNotEmpty() { + assertTrue(_ph.checkIfExists("+37068353981")); + } + + @Test + void testifGoodNumberWhenGoodNumber() { + assertTrue(_ph.checkForOtherSymbols("+37068353981")); + } + + @Test + void testIfGoodNumberWhenThereAreLetters() { + assertFalse(_ph.checkForOtherSymbols("+370abc")); + } + + @Test + void testIfChangesWhenNeeded() { + assertEquals("+370", _ph.changeNumberFormer("868353981")); + } + + @Test + void testIfChangesWhenNotNeeded() { + assertEquals("+370", _ph.changeNumberFormer("+37068353981")); + } + + @Test + void testIfCorrectCountryValidationWhenCorrect() { + assertTrue(_ph.checkForValidCountryNumber("+37168353981", "LV")); + } + + @Test + void testIfCorrectCountryValidationWhenWrong() { + assertFalse(_ph.checkForValidCountryNumber("+37068353981", "LV")); + } +} diff --git a/Task3/src/com/vartotojai/Validators.java b/Task3/src/com/vartotojai/Validators.java new file mode 100644 index 0000000..752f54a --- /dev/null +++ b/Task3/src/com/vartotojai/Validators.java @@ -0,0 +1,34 @@ +package com.vartotojai; +/** + * This bridges imported library (to easier switch for different library) + * */ +import com.lib.*; +public class Validators { + private EmailValidator emailValidator = new EmailValidator(); + private PasswordChecker passwordChecker = new PasswordChecker(); + private PhoneValidator phoneValidator = new PhoneValidator(); + public boolean ValidateEmail (String email){ + return emailValidator.checkIfExists(email) && + emailValidator.checkAtSign(email) && + !emailValidator.checkIllegalSymbols(email) && + emailValidator.checkDomain(email); + } + + public boolean ValidatePassword (String password){ + return passwordChecker.checkIfExists(password) && + passwordChecker.checkLenght(password) && + passwordChecker.checkUpperCase(password) && + passwordChecker.checkSpecialSymbol(password); + } + + public boolean ValidatePhone (String phone, String countryCode){ + return phoneValidator.checkIfExists(phone) && + phoneValidator.checkForOtherSymbols(phone) && + phoneValidator.checkForValidCountryNumber(phone, countryCode); + } + + public String NumberFormatChanger(String number){ + if (phoneValidator.changeNumberFormer(number).equals("+370") && number.startsWith("8")) return "+370"+ number.substring(1,number.length()); + return number; + } +} diff --git a/Task3/src/com/vartotojai/Vartotojas.java b/Task3/src/com/vartotojai/Vartotojas.java new file mode 100644 index 0000000..92b5e2a --- /dev/null +++ b/Task3/src/com/vartotojai/Vartotojas.java @@ -0,0 +1,79 @@ +package com.vartotojai; +/** + * Vartotojo object + * */ +public class Vartotojas { + int userID; + String vardas; + String pavarde; + String numeris; + String email; + String adresas; + String slaptazodis; + + public Vartotojas (int id, String vardas, String pavarde, String numeris, String email, String adresas, String slaptazodis){ + this.userID = id; + this.vardas=vardas; + this.pavarde=pavarde; + this.numeris=numeris; + this.email=email; + this.adresas=adresas; + this.slaptazodis=slaptazodis; + } + + public int getUserID() { + return userID; + } + + public void setUserID(int userID) { + this.userID = userID; + } + + public String getVardas() { + return vardas; + } + + public void setVardas(String vardas) { + this.vardas = vardas; + } + + public String getPavarde() { + return pavarde; + } + + public void setPavarde(String pavarde) { + this.pavarde = pavarde; + } + + public String getNumeris() { + return numeris; + } + + public void setNumeris(String numeris) { + this.numeris = numeris; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public String getAdresas() { + return adresas; + } + + public void setAdresas(String adresas) { + this.adresas = adresas; + } + + public String getSlaptazodis() { + return slaptazodis; + } + + public void setSlaptazodis(String slaptazodis) { + this.slaptazodis = slaptazodis; + } +} diff --git a/Task3/src/com/vartotojai/Veiksmai.java b/Task3/src/com/vartotojai/Veiksmai.java new file mode 100644 index 0000000..292c6c1 --- /dev/null +++ b/Task3/src/com/vartotojai/Veiksmai.java @@ -0,0 +1,114 @@ +package com.vartotojai; +/** + * Library actions (add, get, delete, edit) + * */ +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.io.FileWriter; +import java.util.ArrayList; +import java.util.List; + +public class Veiksmai { + List list = new ArrayList(); + Vartotojas temp; + Validators validate = new Validators(); + public Veiksmai(){ + String row; + try { + BufferedReader csvReader = new BufferedReader(new FileReader("src/com/vartotojai/list.csv")); + while ((row = csvReader.readLine()) != null) { + String[] data = row.split(","); + temp = new Vartotojas(Integer.parseInt(data[0]), data[1], data[2], data[3], data[4], data[5], data[6]); + list.add(temp); + } + csvReader.close(); + }catch (Exception e){ + System.out.println("File could not be readed"); + } + } + public int Prideti(String vardas, String pavarde, String numeris, String saliesKodas, String email, String adresas, String slaptazodis){ + int errcode = ValidateAll(numeris, saliesKodas, email, slaptazodis); + if (errcode!=0) return errcode; + + temp = new Vartotojas(idGenerator(list), vardas,pavarde,validate.NumberFormatChanger(numeris),email,adresas,slaptazodis); + list.add(temp); + SaveList(list); + return 0; + } + + public void Istrinti(int id){ + for (Vartotojas zmogus:list) { + if (zmogus.getUserID()==id) { + list.remove(zmogus); + SaveList(list); + break; + } + } + } + + public Vartotojas Istraukti(int id){ + for (Vartotojas zmogus:list) { + if (zmogus.getUserID()==id) { + return zmogus; + } + } + return null; + } + + public int Redakuoti(int id, String vardas, String pavarde, String numeris, String saliesKodas, String email, String adresas, String slaptazodis){ + int errcode = ValidateAll(numeris, saliesKodas, email, slaptazodis); + if (errcode!=0) return errcode; + temp = new Vartotojas(id, vardas, pavarde, numeris,email,adresas,slaptazodis); + for (Vartotojas zmogus:list) { + if (zmogus.getUserID()==id) { + list.set(list.indexOf(zmogus), temp); + SaveList(list); + return 0; + } + } + return 4;//Not found + } + + private int ValidateAll(String numeris, String saliesKodas, String email, String slaptazodis){ + if (!validate.ValidatePhone(numeris, saliesKodas)) return 1; //Bad phone number + if (!validate.ValidateEmail(email)) return 2; //Bad email + if (!validate.ValidatePassword(slaptazodis)) return 3; //Bad password + return 0; + } + + private void SaveList(List list){ + File myObj = new File("src/com/vartotojai/list.csv"); + myObj.delete(); + try { + FileWriter csvWriter = new FileWriter("src/com/vartotojai/list.csv"); + + for (Vartotojas person:list) { + csvWriter.append(String.valueOf(person.getUserID())); + csvWriter.append(","); + csvWriter.append(person.getVardas()); + csvWriter.append(","); + csvWriter.append(person.getPavarde()); + csvWriter.append(","); + csvWriter.append(person.getNumeris()); + csvWriter.append(","); + csvWriter.append(person.getEmail()); + csvWriter.append(","); + csvWriter.append(person.getAdresas()); + csvWriter.append(","); + csvWriter.append(person.getSlaptazodis()); + csvWriter.append("\n"); + } + csvWriter.flush(); + csvWriter.close(); + }catch (Exception e){ + System.out.println("Failed saving file"); + } + + } + + private int idGenerator (List list){ + if (list.isEmpty()) return 0; + return list.get(list.size() - 1).getUserID()+1; + } +} diff --git a/Task3/src/com/vartotojai/list.csv b/Task3/src/com/vartotojai/list.csv new file mode 100644 index 0000000..a9418c4 --- /dev/null +++ b/Task3/src/com/vartotojai/list.csv @@ -0,0 +1,3 @@ +1,Vardenis1,Pavardenis,+37067123456,example@gmail.com,Vilnius,Pogger123@ +2,Mantass,NeMantas,+37065123456,mantas@gmail.com,Kaunas,nicePogger5% +3,Vardenis3,Pavardenis,+37067123456,example@gmail.com,Vilnius,Pogger123@