|
|||||||||
|
|
|
| Collection of tasks on programming. Old version
|
| text, keyboard, moving of maximum element, programming language, class, FAT32, system, or, directive, interface, processor, file |
Inner organization of collection of tasks
All tasks are stored in database. Also I have three groups of utilities in Java. First group is assigned for adding new tasks into database. Second group is for handling tasks in database (deleting, renumerating and so). Utilities of third group generate collection of tasks into text format or as HTML.
Structure of database
Book consists of chapters (table chapters). Every chapter contains nests of tasks (table nests) and paragraphs (table paragraphs). Nests and paragraphs have unified numeration within a chapter. Every nest is a sequence of tasks (table tasks). Every task consists of three text files: task's body, question and answer (table taskfiles). Also we have table chains for connecting tasks-analogs.

Source text of utilite for generating collection of tasks into text format (real version)
import java.io.*;
import java.sql.*;
import java.util.*;
public class gen_full_text {
public static void main(String[] Args) throws Exception {
String url = "jdbc:odbc:Tasker_Info";
String query_chapters = "";
String query_nests = "";
String query_tasks = "";
String query_path = "";
String s_path = "";
String f_name = "";
String stt = "";
BufferedReader inpu = new BufferedReader(
new InputStreamReader(System.in, "Cp866"));
System.out.println("Generation of full collection of tasks into text format");
System.out.println("_____________________________________________");
System.out.println();
System.out.println("Input name of text file without extension");
f_name = inpu.readLine() + ".txt";
BufferedWriter outpu = new BufferedWriter(new FileWriter(f_name));
outpu.newLine();
outpu.write("Collection of tasks on programming");
outpu.newLine();
outpu.write("by Aliaksandr Prykhodzka ");
outpu.newLine();
outpu.newLine();
outpu.newLine();
outpu.newLine();
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection(url, "", "");
Statement stmt_chapters = con.createStatement();
Statement stmt_nests = con.createStatement();
Statement stmt_tasks = con.createStatement();
Statement stmt_path = con.createStatement();
query_path = "select fullpath from fullpath;";
ResultSet rs_path = stmt_path.executeQuery(query_path);
rs_path.next();
s_path = rs_path.getString(1);
rs_path.close();
query_chapters = "select id, name, nn, brief from chapters order by nn;";
int chapters_id = 0;
String chapters_name = "";
int chapters_nn = 0;
String chapters_brief = "";
int nests_id = 0;
String nests_name = "";
int nests_nn = 0;
int tasks_nn = 0;
String tasks_file_body = "";
String tasks_file_question = ""; String tasks_file_answer = "";
ResultSet rs_nests = null;
ResultSet rs_tasks = null;
boolean pr_nests = false;
boolean pr_tasks = false;
int sh = 0;
ResultSet rs_chapters = stmt_chapters.executeQuery(query_chapters);
boolean pr_chapters = rs_chapters.next();
while (pr_chapters) {
chapters_id = rs_chapters.getInt(1);
chapters_name = rs_chapters.getString(2);
chapters_nn = rs_chapters.getInt(3);
chapters_brief = rs_chapters.getString(4);
outpu.write("Глава " + Integer.toString(chapters_nn) + ". " +
chapters_name);
outpu.newLine();
outpu.newLine();
query_nests = "select id, name, nn from nests where (ref_chapter=" +
Integer.toString(chapters_id) + ") order by nn;";
rs_nests = stmt_nests.executeQuery(query_nests);
pr_nests = rs_nests.next();
while (pr_nests) {
nests_id = rs_nests.getInt(1);
nests_name = rs_nests.getString(2);
nests_nn = rs_nests.getInt(3);
outpu.write(" Гнездо " + Integer.toString(nests_nn) + ". " +
nests_name);
outpu.newLine();
outpu.newLine();
query_tasks =
"select taskfiles.filename_body, taskfiles.filename_question, tasks.nn " +
"from taskfiles INNER JOIN tasks ON taskfiles.id=tasks.ref_task where " +
"(tasks.ref_chapter=" + Integer.toString(chapters_id) +
") and " +
"(tasks.ref_nest=" + Integer.toString(nests_id) + ") " +
"order by tasks.nn;";
rs_tasks = stmt_tasks.executeQuery(query_tasks);
pr_tasks = rs_tasks.next();
while (pr_tasks) {
tasks_file_body = rs_tasks.getString(1);
tasks_file_question = rs_tasks.getString(2);
tasks_nn = rs_tasks.getInt(3);
outpu.write(chapters_brief + "." + Integer.toString(nests_nn) +
"." + Integer.toString(tasks_nn));
outpu.newLine();
BufferedReader br = new BufferedReader(new FileReader(s_path +
tasks_file_question));
try {
while (true) {
stt = br.readLine();
outpu.write(stt);
outpu.newLine();
}
} catch (Exception Ex) {}
br.close();
outpu.newLine();
BufferedReader br1 = new BufferedReader(new FileReader(s_path +
tasks_file_body));
try {
while (true) {
stt = br1.readLine();
outpu.write(stt);
outpu.newLine();
}
} catch (Exception Ex) {}
br1.close();
outpu.newLine();
pr_tasks = rs_tasks.next();
}
rs_tasks.close();
outpu.newLine();
outpu.newLine();
pr_nests = rs_nests.next();
}
rs_nests.close();
outpu.newLine();
outpu.newLine();
pr_chapters = rs_chapters.next();
}
rs_chapters.close();
stmt_chapters.close();
stmt_nests.close();
stmt_tasks.close();
stmt_path.close();
con.close();
outpu.flush();
outpu.close();
System.out.println("_____________________________________________");
System.out.println();
System.out.println("Generation of collection of tasks is completed!");
}
}
|