40 lines
1.5 KiB
Java
40 lines
1.5 KiB
Java
package common;
|
||
|
||
import common.enums.TicketType;
|
||
import common.models.Coordinates;
|
||
import common.models.Ticket;
|
||
|
||
import java.io.BufferedReader;
|
||
import java.io.IOException;
|
||
import java.io.PrintWriter;
|
||
|
||
public class Protocol {
|
||
public String processInput(String input) {
|
||
return "Processed input: " + input;
|
||
}
|
||
|
||
public String createTicket(String input, PrintWriter out, BufferedReader in) throws IOException {
|
||
// Псевдокод для демонстрации запроса данных у клиента
|
||
String name = askClient("Введите название билета:", out, in);
|
||
String xStr = askClient("Введите координату X:", out, in);
|
||
int x = Integer.parseInt(xStr);
|
||
// Дополнительные поля аналогично
|
||
|
||
// Создаем объект Ticket после получения всех необходимых данных
|
||
Ticket ticket = new Ticket(
|
||
name,
|
||
new Coordinates(x, 0), // TODO: handle y
|
||
new Long(10000),
|
||
new Long(100),
|
||
TicketType.CHEAP,
|
||
null
|
||
);
|
||
return "Билет создан успешно.";
|
||
}
|
||
|
||
private String askClient(String question, PrintWriter out, BufferedReader in) throws IOException {
|
||
out.println(question); // Отправляем запрос клиенту
|
||
return in.readLine(); // Ждем ответ от клиента
|
||
}
|
||
}
|