АвтоАвтоматизацияАрхитектураАстрономияАудитБиологияБухгалтерияВоенное делоГенетикаГеографияГеологияГосударствоДомДругоеЖурналистика и СМИИзобретательствоИностранные языкиИнформатикаИскусствоИсторияКомпьютерыКулинарияКультураЛексикологияЛитератураЛогикаМаркетингМатематикаМашиностроениеМедицинаМенеджментМеталлы и СваркаМеханикаМузыкаНаселениеОбразованиеОхрана безопасности жизниОхрана ТрудаПедагогикаПолитикаПравоПриборостроениеПрограммированиеПроизводствоПромышленностьПсихологияРадиоРегилияСвязьСоциологияСпортСтандартизацияСтроительствоТехнологииТорговляТуризмФизикаФизиологияФилософияФинансыХимияХозяйствоЦеннообразованиеЧерчениеЭкологияЭконометрикаЭкономикаЭлектроникаЮриспунденкция

The progress of work

Читайте также:
  1. Listen again and see how the conversation between Christopher Thorn and Mr. Roberts progressed. Try to complete the gaps, using no more than three words in each case.
  2. Listen to the following extract from the recording which shows how the situation progressed. Try to complete the gaps, using no more than three words in each case.
  3. Positive Feedback as a Multiplier for Progress
  4. Present Simple and Present Progressive
  5. The Progress of Science

Abstract

Кроссворд (англ. Crossword — пересечение слов) — «крестословица», «плетенки», «пирамиды», «дорожки», «магические квадраты»; головоломка, представляющая собой переплетение рядов клеточек, которые заполняются словами по заданным значениям.

Обычно значения слов задаются описательно под этой фигурой, сначала значения слов, которые должны получиться по горизонтали, затем — по вертикали.

The progress of work

1. Algorithm and block scheme of main project

2. Methods and process description (functions, objects, methods)

class Crossword

class CrosswordMain

showAnswers()

closeAnswers()

Crossword()

3. Code description for main parts in program

 

private static int windowWidth = 600; // The width of the window in pixels

private static int windowHeight = 600; // The height of the window in pixels

private static Dimension frameSize;

private static Dimension screenSize;

private static final String DATA_PATH = "dataFileQuest.txt";//path for reading from file of questions

private static final String DATA_PATH2 = "words.txt";//path for reading from file of words and coordinates

private JLabel[] labels = new JLabel[100]; //labels for questions

private JTextField[][] verField = new JTextField[50][50]; // text fields for vertical words

private JTextField[][] horField = new JTextField[50][50];// text fields for horizontal words

private JButton show = new JButton("Show answers"); // button for showing answers

private JButton close = new JButton("Close answers");// button for closing answers

public int horInd = 0; // variable for saving index of starting of horizontal words

ArrayList<String> arrLines = new ArrayList<String>(); // array to store all words and coordinates as string

ArrayList<String> arrWords = new ArrayList<String>(); //store only words

ArrayList<Integer> arrX = new ArrayList<>(); //store all X-coordinates

ArrayList<Integer> arrY = new ArrayList<>();//store all Y-coordinates

ArrayList<Integer> verArrY = new ArrayList<>();

ArrayList<Integer> verArrX = new ArrayList<>();

JLabel[] numLab = new JLabel[50]; // to enumerate words

 

Scanner fileReader = null; // scanner to read file of questions

try {

fileReader = new Scanner(new File(DATA_PATH)); // if our file is found

} catch (FileNotFoundException e) { // exception if file isn't found

System. out. println("The file " + DATA_PATH + " was not found!");

System. exit (0);

}

 

Scanner wordsReader = null;// scanner to read file of words and coordinates

try {

wordsReader = new Scanner(new File(DATA_PATH2));// if our file is found

} catch (FileNotFoundException e) { // exception if file isn't found

System. out. println("The file " + DATA_PATH2 + " was not found!");

System. exit (0);

}

4. Results

 

Application. Program code with comments

                       
   
Кнопка — показать ответы
   
 
 
 
 
   
 
   
Label для вопросов
   
 

 


this.setTitle("Ablakasova Gulshat");

this. setDefaultCloseOperation(JFrame. EXIT_ON_CLOSE);

int count = 0;

 

show.setFont(new java.awt.Font("Dialog", Font. BOLD, 20));

show.setBounds(new Rectangle(5, 15, 200, 50));

show.setBackground(Color. LIGHT_GRAY);

show.setForeground(Color. WHITE);

show.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent ae) {

showAnswers();

}

});

 

close.setFont(new java.awt.Font("Dialog", Font. BOLD, 20));

close.setBounds(new Rectangle(5, 65, 200, 50));

close.setBackground(Color. LIGHT_GRAY);

close.setForeground(Color. WHITE);

close.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent ae) {

closeAnswers();

}

});

 

Scanner fileReader = null; // scanner to read file of questions

try {

fileReader = new Scanner(new File(DATA_PATH)); // if our file is found

} catch (FileNotFoundException e) { // exception if file isn't found

System. out. println("The file " + DATA_PATH + " was not found!");

System. exit (0);

}

 

ArrayList<String> arrLabel = new ArrayList<String>();

 

while (fileReader.hasNextLine())

arrLabel.add(fileReader.nextLine());

 

int LabelLocate = 600 - ((arrLabel.size() + 1) * 30);

 

for (int i = 0; i < arrLabel.size(); i++) {

labels[i] = new JLabel(arrLabel.get(i));

labels[i].setFont(new java.awt.Font("Times New Roman", Font. ITALIC,

18));

labels[i].setBounds(new Rectangle(0, LabelLocate, 590, 24));

labels[i].setForeground(Color. blue);

LabelLocate += 30;

}

 

Scanner wordsReader = null;// scanner to read file of words and coordinates

try {

wordsReader = new Scanner(new File(DATA_PATH2));// if our file is found

} catch (FileNotFoundException e) { // exception if file isn't found

System. out. println("The file " + DATA_PATH2 + " was not found!");

System. exit (0);

}

wordsReader.next();

while (wordsReader.hasNext())

arrLines.add(wordsReader.next());

 

for (int i = 0; i < arrLines.size(); i++)

if (arrLines.get(i).charAt(0) == 'H') {

arrLines.remove(i);

if (horInd % 2 == 0)

horInd = i / 2;

Else

horInd = i / 2 + 1;

}

 

for (int i = 0; i < arrLines.size() - 1; i++) {

arrWords.add(arrLines.get(i));

i++;

arrX.add(Integer. parseInt (arrLines.get(i)));

i++;

arrY.add(Integer. parseInt (arrLines.get(i)));

}

 

for (int i = 0; i < horInd - 1; i++) {

int y = arrY.get(i);

for (int j = 0; j < arrWords.get(i).length(); j++) {

verField[i][j] = new JTextField();

verField[i][j].setText("");

verField[i][j].setFont(new java.awt.Font("Dialog", Font. PLAIN,

18));

verField[i][j].setBounds(new Rectangle(arrX.get(i), y, 30, 30));

verArrY.add(y);

verArrX.add(arrX.get(i));

y = y + 30;

}

Integer num = i + 1;

String n = num.toString();

numLab[i] = new JLabel(n);

numLab[i].setFont(new java.awt.Font("Dialog", Font. BOLD, 13));

numLab[i].setBounds(new Rectangle(arrX.get(i) + 5,

arrY.get(i) - 20, 15, 24));

numLab[i].setForeground(Color. WHITE);

}

 

for (int i = horInd - 1; i < arrX.size(); i++) {

int x = arrX.get(i);

 

for (int j = 0; j < arrWords.get(i).length(); j++) {

horField[i][j] = new JTextField();

horField[i][j].setText("");

horField[i][j].setFont(new java.awt.Font("Dialog", Font. PLAIN,

18));

horField[i][j].setBounds(new Rectangle(x, arrY.get(i), 30, 30));

x = x + 30;

}

Integer num = i + 1;

String n = num.toString();

numLab[i] = new JLabel(n);

numLab[i].setFont(new java.awt.Font("Dialog", Font. BOLD, 13));

numLab[i].setBounds(new Rectangle(arrX.get(i) - 15, arrY.get(i),

15, 24));

numLab[i].setForeground(Color. WHITE);

}

 

int maxY = arrY.get(0);

for (int i = 0; i < arrY.size(); i++)

if (maxY < arrY.get(i))

maxY = arrY.get(i);

 

int maxX = arrX.get(0);

for (int i = 0; i < arrY.size(); i++)

if (maxX < arrX.get(i))

maxX = arrX.get(i);

 

windowWidth = maxX + 150;

windowHeight = LabelLocate + 30;

frameSize = new Dimension(windowWidth, windowHeight);

screenSize = Toolkit. getDefaultToolkit ().getScreenSize();

 

JPanel contentPane = (JPanel) this. getContentPane();

contentPane.setLayout(null);

contentPane.setBackground(Color. lightGray);

for (int i = 0; i < arrLabel.size(); i++)

contentPane.add(labels[i]);

 

for (int i = 0; i < horInd - 1; i++)

for (int j = 0; j < arrWords.get(i).length(); j++)

contentPane.add(verField[i][j]);

for (int i = horInd - 1; i < arrX.size(); i++)

for (int j = 0; j < arrWords.get(i).length(); j++)

contentPane.add(horField[i][j]);

 

for (int i = 0; i < arrX.size(); i++)

contentPane.add(numLab[i]);

contentPane.add(show);

contentPane.add(close);

JLabel imageLabel = new JLabel(new ImageIcon("myimage.jpg"));

imageLabel.setBounds(0, -100, windowWidth, windowHeight);

contentPane.add(imageLabel);

 

this. setSize(frameSize. width + 10, frameSize. height + 10);

this. setLocation((screenSize. width - frameSize. width) / 2,

(screenSize. height - frameSize. height) / 2);

 

this. setVisible(true);

}

 

public void showAnswers() {

for (int i = 0; i < horInd - 1; i++)

for (int j = 0; j < arrWords.get(i).length(); j++) {

char [] t = new char [1];

t[0] = arrWords.get(i).charAt(j);

String s = new String(t);

verField[i][j].setText(s);

}

for (int i = horInd - 1; i < arrX.size(); i++)

for (int j = 0; j < arrWords.get(i).length(); j++) {

char [] t = new char [1];

t[0] = arrWords.get(i).charAt(j);

String s = new String(t);

horField[i][j].setText(s);

}

}

 

public void closeAnswers() {

for (int i = 0; i < horInd - 1; i++)

for (int j = 0; j < arrWords.get(i).length(); j++) {

verField[i][j].setText("");

}

for (int i = horInd - 1; i < arrX.size(); i++)

for (int j = 0; j < arrWords.get(i).length(); j++) {

horField[i][j].setText("");

}

}

Во время учебной практики по программированию я успела решить задачи на разные темы разных сложностей. Так же повторила весь изученный материал за первый курс. Написала проект на языке Java.


Поиск по сайту:



Все материалы представленные на сайте исключительно с целью ознакомления читателями и не преследуют коммерческих целей или нарушение авторских прав. Студалл.Орг (0.022 сек.)