Автор работы: Пользователь скрыл имя, 30 Октября 2013 в 00:09, курсовая работа
Об'єктно-орієнтоване програмування — одна з парадигм програмування, яка розглядає програму, як множину “об'єктів”, що взаємодіють між собою. В ній використано декілька технологій від попередніх парадигм, зокрема успадкування, модульність, поліморфізм та інкапсуляцію. Не зважаючи на те, що ця парадигма з'явилась в 1960-тих роках, вона не мала широкого застосування до 90-х років. На сьогодні багато із мов програмування підтримують ООП. Серед яких є С++, Java, Objective-C, Clips, Python, PHP. В даній курсовій роботі ми будемо використовувати мову програмування Java, яка є зручним інстрементом для реалізаціі функціоналу, та створення графічного інтерфейсу програми.
Вступ.........................................................................................................................4
1. Об’єктно-орієнтована побудова логічних схем. Постанова задачі та основні визначення.............................................................................................................5
2. Відомості о Java................................................................................................6
3. Іднівідуальне завдання.....................................................................................7
4. Інструкціі по експлуатаціі розробленої програми.........................................8
5. Тестування роботи програми згідно з заданим варіантом............................10
Висновки………………………………………………………………..…..…....11
Список літератури……………………………………….............................……12
Додаток 1. Код програми
static ArrayList<Boolean> elementListOr = new ArrayList<Boolean>();
static ArrayList<Boolean> elementListXor = new ArrayList<Boolean>();
static ArrayList<Boolean> elementListNand = new ArrayList<Boolean>();
static ArrayList<JLabel> eLJLabelListNot = new ArrayList<JLabel>();
static ArrayList<JLabel> eLJLabelListAnd = new ArrayList<JLabel>();
static ArrayList<JLabel> eLJLabelListOr = new ArrayList<JLabel>();
static ArrayList<JLabel> eLJLabelListXor = new ArrayList<JLabel>();
static ArrayList<JLabel> eLJLabelListNand = new ArrayList<JLabel>();
static JTextField s1Field = new JTextField();
static JTextField s2Field = new JTextField();
static JTextField s3Field = new JTextField();
static JTextField s4Field = new JTextField();
static JTextField s5Field = new JTextField();
static JTextField s6Field = new JTextField();
static JTextField siField = new JTextField();
static JTextField sjField = new JTextField();
static JTextField operatorField = new JTextField("");
static JTextField soField = new JTextField();
//static JTextField elementXPositionField = new JTextField();
//static JTextField elementYPositionField = new JTextField();
static JTextField l1Field = new JTextField();
static JTextField l2Field = new JTextField();
static JTextField l3Field = new JTextField();
//</editor-fold>
static JButton addButton = new JButton("ADD ELEMENT");
static JButton calculateButton = new JButton("CLEAR ALL!");
static String finded[] = new String[2];
static String ivarToCalcFunc;
static String jvarToCalcFunc;
static GraphicsPanel gP = new GraphicsPanel();
public static void main(String[] args) {
JFrame mainFrame = new JFrame("Schema Logic 3.0");
mainFrame.
mainFrame.setVisible(true);
//<editor-fold defaultstate="collapsed" desc="Boxes">
Box mainBox = Box.createVerticalBox();
Box signalBox = Box.createHorizontalBox();
Box inputBox = Box.createHorizontalBox();
Box graphicsBox = Box.createHorizontalBox();
Box outputBox = Box.createHorizontalBox();
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="Labels">
JLabel s1Label = new JLabel("s1 : ");
JLabel s2Label = new JLabel("s2 : ");
JLabel s3Label = new JLabel("s3 : ");
JLabel s4Label = new JLabel("s4 : ");
JLabel s5Label = new JLabel("s5 : ");
JLabel s6Label = new JLabel("s6 : ");
JLabel siLabel = new JLabel("si: ");
JLabel operatorLabel = new JLabel("do:");
JLabel sjLabel = new JLabel("sj: ");
JLabel eqLabel = new JLabel(" = ");
//JLabel elementXPositionLabel = new JLabel("x: ");
//JLabel elementYPositionLabel = new JLabel("y: ");
//</editor-fold>
addButton.addActionListener(
calculateButton.
l1Field.setEditable(false);
l2Field.setEditable(false);
l3Field.setEditable(false);
//<editor-fold defaultstate="collapsed" desc="Signal box adding">
signalBox.add(s1Label);
signalBox.add(s1Field);
signalBox.add(s2Label);
signalBox.add(s2Field);
signalBox.add(s3Label);
signalBox.add(s3Field);
signalBox.add(s4Label);
signalBox.add(s4Field);
signalBox.add(s5Label);
signalBox.add(s5Field);
signalBox.add(s6Label);
signalBox.add(s6Field);
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="Input box adding">
inputBox.add(siLabel);
inputBox.add(siField);
inputBox.add(Box.
inputBox.add(operatorLabel);
inputBox.add(operatorField);
inputBox.add(Box.
inputBox.add(sjLabel);
inputBox.add(sjField);
inputBox.add(eqLabel);
inputBox.add(soField);
inputBox.add(Box.
// inputBox.add(
// inputBox.add(
// inputBox.add(
// inputBox.add(
inputBox.add(addButton);
inputBox.add(calculateButton);
//</editor-fold>
// graphicsBox.add(graphicsLabel)
//<editor-fold defaultstate="collapsed" desc="Output box adding">
outputBox.add(Box.
outputBox.add(l1Field);
outputBox.add(l2Field);
outputBox.add(l3Field);
outputBox.add(Box.
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="pack">
mainBox.add(signalBox);
mainBox.add(Box.
mainBox.add(inputBox);
mainBox.add(Box.
mainBox.add(graphicsBox);
mainBox.add(Box.
mainBox.add(outputBox);
mainFrame.setContentPane(
mainFrame.pack();
mainFrame.setSize(500, 200);
mainFrame.setResizable(false);
//</editor-fold>
}
private static class ButtonListener implements ActionListener {
static JFrame graphicsFrame;
public ButtonListener() {
}
public static Boolean intoBool(int bool) {
Boolean b = null;
if (bool == 1) {
b = true;
} else if (bool == 0) {
b = false;
}
return b;
}
@Override
public void actionPerformed(ActionEvent e) {
if ("ADD ELEMENT".equals(e.
if (graphicsFrame == null) {
graphicsFrame = new JFrame("Schema Graphics 1.0");
graphicsFrame.
graphicsFrame.setVisible(true)
graphicsFrame.
graphicsFrame.setContentPane(
graphicsFrame.pack();
}
try {
//<editor-fold defaultstate="collapsed" desc="si Switch ">
switch (siField.getText()) {
case "s1":
ivarToCalcFunc = (s1Field.getText());
break;
case "s2":
ivarToCalcFunc = (s2Field.getText());
break;
case "s3":
ivarToCalcFunc = (s3Field.getText());
break;
case "s4":
ivarToCalcFunc = (s4Field.getText());
break;
case "s5":
ivarToCalcFunc = (s5Field.getText());
break;
case "s6":
ivarToCalcFunc = (s6Field.getText());
break;
default:
finded = (siField.getText()).split(":")
switch (finded[0]) {
case "x":
case "a":
ivarToCalcFunc = String.valueOf(elementListNot.
ivarToCalcFunc = String.valueOf(elementListOr.
}
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="sj Switch">
switch (sjField.getText()) {
case "s1":
jvarToCalcFunc = (s1Field.getText());
break;
case "s2":
jvarToCalcFunc = (s2Field.getText());
break;
case "s3":
jvarToCalcFunc = (s3Field.getText());
break;
case "s4":
jvarToCalcFunc = (s4Field.getText());
break;
case "s5":
jvarToCalcFunc = (s5Field.getText());
break;
case "s6":
jvarToCalcFunc = (s6Field.getText());
break;
default:
finded = (sjField.getText()).split(":")
switch (finded[0]) {
jvarToCalcFunc = String.valueOf(elementListXor.
jvarToCalcFunc =
String.valueOf(elementListAnd.
}
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="Operator Switcher">
switch (operatorField.getText()) {
case "&&":
System.out.println("&&");
System.out.println(
System.out.println(
addNewElementToList(
break;
case "||":
System.out.println("||");
System.out.println(
System.out.println(
addNewElementToList(
break;
case "!":
System.out.println("!");
System.out.println(
System.out.println(
addNewElementToList(
break;
case "^":
System.out.println("^");
System.out.println(
System.out.println(
addNewElementToList(
break;
case "!&":
System.out.println("!&");
System.out.println(
System.out.println(
addNewElementToList(
break;
case "->":
if (soField.getText().equals("L1"
} else if (soField.getText().equals("L2"
} else if (soField.getText().equals("L3"
}
break;
}
//</editor-fold>
} catch (NumberFormatException | HeadlessException exception) {
System.out.println("ERROR OF INPUT" + exception);
}
} else if ("CLEAR ALL!".equals(e.
try {
new ProcessBuilder("cmd", "/c", "start", "C:/my.bat").start();
System.exit(0);
Информация о работе Об’єктно-орієнтована побудова логічних схем