Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
2 changes: 1 addition & 1 deletion .idea/libraries/xalan2.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/libraries/xalan5.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

793 changes: 793 additions & 0 deletions .idea/workspace.xml

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions console/src/user_interface/ChangeHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ protected static void countryChanger() {
PrintHandler.printArrayCountries(Resources.countries);
// Выбор страны для изменения
int choice = Integer.parseInt(MainMenu.reader.readLine());
if (choice < UserData.countryCount) {
if (choice >= 0 && choice < Resources.countries.size()) {
changeCountry(choice);
} else {
throw new IndexOutOfBoundsException();
Expand All @@ -50,7 +50,7 @@ protected static void countryChanger() {
} catch (IOException e) {
MainMenu.out.println(Resources.language.getIO_ERROR());
} catch (IndexOutOfBoundsException e) {
Resources.language.getWRONG_CHOICE();
MainMenu.out.println(Resources.language.getWRONG_CHOICE());
}
}

Expand Down
6 changes: 3 additions & 3 deletions console/src/user_interface/PrintHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -202,17 +202,17 @@ private static void printOwnHolidays(){
if (UserData.currentUser != null && !UserData.currentUser.isAdmin()){
if (!UserData.currentUser.getHolidayList().isEmpty()){
ArrayList<Tradition> traditions = new ArrayList<Tradition>();
for (int i = UserData.traditionCount; i < Resources.traditions.size(); i++){
for (int i = 0; i < Resources.traditions.size(); i++){
traditions.add(Resources.traditions.get(i));
}
UserData.currentUser.setTraditionList(traditions);
LinkedList<Country> countries = new LinkedList<Country>();
for (int i = UserData.countryCount; i < Resources.countries.size(); i++){
for (int i = 0; i < Resources.countries.size(); i++){
countries.add(Resources.countries.get(i));
}
UserData.currentUser.setCountryList(countries);
LinkedList<Holiday> holidays = new LinkedList<Holiday>();
for (int i = UserData.holidayCount; i < Resources.holidays.size(); i++){
for (int i = 0; i < Resources.holidays.size(); i++){
holidays.add(Resources.holidays.get(i));
}
UserData.currentUser.setHolidayList(holidays);
Expand Down
4 changes: 2 additions & 2 deletions console/src/user_interface/RemoveHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ protected static void holidayRemover() {
try {
MainMenu.out.println(Resources.language.getID_REQUEST());
int id = Integer.parseInt(MainMenu.reader.readLine());
if (id >= UserData.holidayCount && id < Resources.holidays.size()) {
if (id >= 0 && id < Resources.holidays.size()) {
removeHoliday(id);
}
else {
Expand All @@ -31,7 +31,7 @@ protected static void countryRemover() {
try {
MainMenu.out.println(Resources.language.getID_REQUEST());
int id = Integer.parseInt(MainMenu.reader.readLine());
if (id >= UserData.countryCount && id < Resources.countries.size()) {
if (id >= 0 && id < Resources.countries.size()) {
removeCountry(id);
}
else {
Expand Down
6 changes: 3 additions & 3 deletions console/src/user_interface/SearchHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ protected static void searchMenu() {
}
}

private static void searchVoid() {
private static void searchVoid() { //вызов обычного поиски
try {
MainMenu.out.println(Resources.language.getSEARCH_REQUEST());
String request = MainMenu.reader.readLine();
Expand All @@ -53,7 +53,7 @@ private static void searchVoid() {
searchMenu();
}

private static void maskSearchVoid() {
private static void maskSearchVoid() { //вызов поиска по маске
try {
String country, holiday, description = "";
MainMenu.out.println(Resources.language.getCOUNTRY_REQUEST());
Expand All @@ -70,7 +70,7 @@ private static void maskSearchVoid() {
searchMenu();
}

private static void regularSearchVoid() {
private static void regularSearchVoid() { //вызов поиска по регулярным выражениям
try {
MainMenu.out.println(Resources.language.getSEARCH_REQUEST());
String request = MainMenu.reader.readLine();
Expand Down
4 changes: 2 additions & 2 deletions console/src/user_interface/TraditionHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

public class TraditionHandler {

public static void traditionMenu() {
public static void traditionMenu() { //меню работы с традициями
if (UserData.currentUser != null) {
MainMenu.out.println(Resources.language.getTRADITION_MENU());
}
Expand Down Expand Up @@ -46,7 +46,7 @@ public static void traditionMenu() {
}
}

private static void printDescription() {
private static void printDescription() { //вывод описания традиции
MainMenu.out.println(Resources.language.getID_REQUEST());
try {
int id = Integer.parseInt(MainMenu.reader.readLine());
Expand Down
35 changes: 14 additions & 21 deletions console/src/user_interface/UserHandler.java
Original file line number Diff line number Diff line change
@@ -1,22 +1,14 @@
package user_interface;

import functional.*;
import model.*;
import org.jdom2.JDOMException;
import org.xml.sax.SAXException;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.LinkedList;

//import modules.functional.DataSaveLoad;
//import modules.functional.SerFileWorking;
//import modules.functional.XmlFileWorking;

/**
* Created by root on 15.03.15.
Expand All @@ -25,6 +17,10 @@ public class UserHandler {
protected static PrintWriter out = new PrintWriter(System.out, true);
protected static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

/*************************
* Methods
*************************/
//Сам метод регистрации.
private static void registration() {
String login,
pass1,
Expand All @@ -46,20 +42,19 @@ private static void registration() {
break;
}
} catch (IllegalArgumentException e) {
out.println(e.getMessage());
registration();
out.println(Resources.language.getWRONG_CHOICE());
} catch (IOException e) {
out.println(Resources.language.getIO_ERROR());
MainMenu.mainMenu();
} catch (JDOMException e) {
e.printStackTrace();
out.println(Resources.language.getXML_ERROR());
} catch (SAXException e) {
e.printStackTrace();
out.println(Resources.language.getXML_ERROR());
} catch (ParseException e) {
e.printStackTrace();
out.println(Resources.language.getPARSE_ERROR());
}
}

//Автроизация пользователя.
private static void authorization() throws JDOMException, SAXException, ParseException {
String login,
pass;
Expand All @@ -76,9 +71,8 @@ private static void authorization() throws JDOMException, SAXException, ParseExc
MainMenu.mainMenu();
}
}

//Загрузка даных пользователя.
protected static void loadUserData(String login, String pass) throws JDOMException, SAXException, ParseException, IOException {

String message = UserData.loadData(login, pass, Resources.traditions, Resources.countries,
Resources.holidays);
if (!message.isEmpty()) {
Expand All @@ -87,13 +81,12 @@ protected static void loadUserData(String login, String pass) throws JDOMExcepti
}
else out.println(Resources.language.getHELLO_USER() + login);
}

//Меню авторизации.
protected static void logIn() {
out.println(Resources.language.getENTER_MESSAGE());
int choice;
try {
choice = Integer.parseInt(reader.readLine());

switch (choice) {
case 1:
authorization();
Expand All @@ -116,11 +109,11 @@ protected static void logIn() {
out.println(Resources.language.getIO_ERROR());
logIn();
} catch (JDOMException e) {
e.printStackTrace();
out.println(Resources.language.getXML_ERROR());
} catch (SAXException e) {
e.printStackTrace();
out.println(Resources.language.getXML_ERROR());
} catch (ParseException e) {
e.printStackTrace();
out.println(Resources.language.getPARSE_ERROR());
}
}

Expand Down
Loading