Список использованных источников
TeachersTableModel ttm = new TeachersTableModel (new String{" ФИО учителя", «Предмет», «Недельная нагрузка» }); PupilsTimeTableModel pttm = new PupilsTimeTableModel (new String{" Класс", «Урок», «Понедельник», «Вторник» ,. Рисунок А.3 — «Декомпозиция блока Составить расписание для учителей». Рисунок А.4 — «Декомпозиция блока Проверить правильность». Public void Connect () throws IOException… Читать ещё >
Список использованных источников (реферат, курсовая, диплом, контрольная)
1. Java. Методы программирования. Блинов И. Н., Романчик В. С. — Минск: Издательство «Четыре четверти», 2013.
ПРИЛОЖЕНИЯ
Приложение А
(обязательное)
Функциональная модель разработки расписания занятий
Рисунок А.1 — «Контекстная диаграмма».
Рисунок А.2 — «Декомпозиция контекстной диаграммы».
Продолжение приложения А.
Рисунок А.3 — «Декомпозиция блока Составить расписание для учителей».
Рисунок А.4 — «Декомпозиция блока Проверить правильность».
Приложение Б
Листинг кода ключевых классов
public class ClientConnector {.
//static ServerSocket variable.
private static ServerSocket server;
//socket server port on which it will listen.
// private static int port;
public ClientConnector () throws IOException {.
/**.
* Reading info about port from file*/.
BufferedReader fis = new BufferedReader (new InputStreamReader (new FileInputStream («port.txt»)));
String line = fis. readLine ();
fis.close ();
server = new ServerSocket (Integer.parseInt (line));
}.
public void Connect () throws IOException, ClassNotFoundException, InterruptedException, SQLException {.
while (true){.
System.out.println («Waiting for client request…»);
//creating socket and waiting for client connection.
Socket socket = server. accept ();
//read from socket to ObjectInputStream object.
ObjectInputStream ois = new ObjectInputStream (socket.getInputStream ());
ObjectOutputStream oos = new ObjectOutputStream (socket.getOutputStream ());
oos.writeObject («Server connected»);
while (true){.
String str = (String) ois. readObject ();
if (str.equals («sending school»)) {.
System.out.println (str);
School school;
school = (School) ois. readObject ();
ObjectOutputStream out = new ObjectOutputStream (new FileOutputStream («school.txt»));
out.writeObject (school);
}.
if (str.equals («send call table»)) {.
System.out.println (str);
CallTableModel ctm = new CallTableModel (new String[]{" Урок", «Начало», «Конец» });
CallTableOperation cto = new CallTableOperation ();
ctm = cto. initRows (ctm);
oos.writeObject (ctm);
}.
if (str.equals («Client connected»)).
System.out.println (str);
if (str.equals («update call table»)).
{.
System.out.println (str);
CallTableModel ctm;
ctm = (CallTableModel) ois. readObject ().
CallTableOperation cto = new CallTableOperation ();
cto.update (ctm);
}.
if (str.equals («send teachers table»)){.
System.out.println (str);
TeachersTableModel ttm = new TeachersTableModel (new String[]{" ФИО учителя", «Предмет», «Недельная нагрузка» });
TeachersTableOperation tto = new TeachersTableOperation ();
ttm = tto. initRows (ttm);
oos.writeObject (ttm);
}.
if (str.equals («update teachers table»)).
{.
System.out.println (str);
TeachersTableModel ttm;
ttm = (TeachersTableModel) ois. readObject ();
TeachersTableOperation tto = new TeachersTableOperation ();
tto.update (ttm);
}.
if (str.equals («send classes table»)){.
System.out.println (str);
ClassesTableModel ctm = new ClassesTableModel (new String[]{" Параллель", «Буква» });
ClassesTableOperation cto = new ClassesTableOperation ();
ctm = cto. init (ctm);
oos.writeObject (ctm);
}.
if (str.equals («update classes table»)).
{.
System.out.println (str);
ClassesTableModel ctm;
ctm = (ClassesTableModel) ois. readObject ();
ClassesTableOperation cto = new ClassesTableOperation ();
cto.update (ctm);
}.
if (str.equals («exit»)){.
break;
}.
if (str.equals («send school»)) {.
System.out.println (str);
ObjectInputStream in = new ObjectInputStream (new FileInputStream («school.txt»));
School school = (School)in.readObject ();
oos.writeObject (school);
}.
if (str.equals («sending teacherstimetable»)) {.
System.out.println (str);
TeachersTimeTableModel tttm;
TeachersTimeTableOperation ttto = new TeachersTimeTableOperation ();
tttm = (TeachersTimeTableModel) ois. readObject ();
ttto.update (tttm);
}.
if (str.equals («send teacherstimetable»)) {.
System.out.println (str);
TeachersTimeTableModel tttm = new TeachersTimeTableModel (new String[]{" Учитель", «Время», «Понедельник», «Вторник» ,.
Среда", «Четверг», «Пятница», «Суббота» });
TeachersTimeTableOperation ttto = new TeachersTimeTableOperation ();
tttm = ttto. init (tttm);
oos.writeObject (tttm);
}.
ois.close ();
oos.close ();
socket.close ();
public class MySQLConnector {.
private static final String URL = «jdbc:mysql://localhost:3306/timetable» ;
private static final String USERNAME = «root» ;
private static final String PASSWORD = «root» ;
private Connection connection;
public Connection getConnection () {.
return connection;
}.
public MySQLConnector (){.
try {.
Driver driver = new FabricMySQLDriver ();
DriverManager.registerDriver (driver);
connection = DriverManager. getConnection (URL, USERNAME, PASSWORD);
}.
catch (SQLException e){.
e.printStackTrace ();
}.
}.
public ResultSet executeQuery (String query) throws SQLException {.
Statement statement = this. getConnection ().createStatement ();
ResultSet res = statement. executeQuery (query);
return res;
}.
public class GeneratePupilsTable {.
public GeneratePupilsTable (){}.
public Object replaceTeachersAndSubjects (Object object) throws ClassNotFoundException, UnsupportedLookAndFeelException, InstantiationException, IllegalAccessException, IOException {.
TeachersTableModel ttm;
ServerConnector connector = new ServerConnector ();
connector.setOnlineMode ();
connector.sendToServer («send teachers table»);
ttm = (TeachersTableModel) connector. receive (connector.getOis ());
connector.setOffLineMode ();
for (int i = 0; i < ttm. getRowCount (); i++) {.
if (ttm.getValueAt (i, 0).equals (object)) {.
object = String. valueOf (ttm.getValueAt (i, 1));
break;
}.
}.
return object;
}.
public List returnLessons () throws ClassNotFoundException, UnsupportedLookAndFeelException, InstantiationException, IllegalAccessException, IOException {.
CallTableModel ctm;
ServerConnector connector = new ServerConnector ();
connector.setOnlineMode ();
connector.sendToServer («send call table»);
ctm = (CallTableModel) connector. receive (connector.getOis ());
connector.setOffLineMode ();
String element;
List list = new ArrayList ();
for (int i = 0; i < ctm. getRowCount (); i++) {.
element = String. valueOf (ctm.getValueAt (i, 0));
list.add (i, element);
}.
return list;
}.
public List returnClasses () throws ClassNotFoundException, UnsupportedLookAndFeelException, InstantiationException, IllegalAccessException, IOException {.
assesTableModel ctm;
ServerConnector connector = new ServerConnector ();
connector.setOnlineMode ();
connector.sendToServer («send classes table»);
ctm = (ClassesTableModel) connector. receive (connector.getOis ());
connector.setOffLineMode ();
String element;
List list = new ArrayList ();
for (int i = 0; i < ctm. getRowCount (); i++) {.
String part1 = String. valueOf (ctm.getValueAt (i, 0));
String part2 = String. valueOf (ctm.getValueAt (i, 1));
element = part1 + part2;
list.add (i, element);
}.
return list;
}.
public PupilsTimeTableModel generatePupilsTimeTable () throws IOException, ClassNotFoundException, UnsupportedLookAndFeelException, InstantiationException, IllegalAccessException {.
ServerConnector connector = new ServerConnector ();
connector.setOnlineMode ();
connector.sendToServer («send teacherstimetable»);
TeachersTimeTableModel tttm = (TeachersTimeTableModel) connector. receive (connector.getOis ());
connector.setOffLineMode ();
PupilsTimeTableModel pttm = new PupilsTimeTableModel (new String[]{" Класс", «Урок», «Понедельник», «Вторник» ,.
" Среда", «Четверг», «Пятница», «Суббота» });
List classes = this. returnClasses ();
List lessons = this. returnLessons ();
for (int i = 0; i < classes. size (); i++).
for (int j = 0; j < lessons. size (); j++).
pttm.addRow (new String[] {classes.get (i), lessons. get (j), «», «», «», «», «», «» });
for (int i = 0; i < tttm. getRowCount (); i++).
for (int j = 2; j < tttm. getColumnCount (); j++).
{.
String element = String. valueOf (tttm.getValueAt (i, j));
for (int k = 0; k < pttm. getRowCount (); k++).
{.
if (pttm.getValueAt (k, 0).equals (element)){.
int q = i%lessons.size ();
pttm.setValueAt (replaceTeachersAndSubjects (tttm.getValueAt (i, 0)), (q+k), j);
break;
return pttm;