Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
KateOrient authored Sep 7, 2017
1 parent f999e5e commit c697f7d
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 0 deletions.
58 changes: 58 additions & 0 deletions Format/Format.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package Format;

import java.io.*;
import java.util.*;

public class Format {
final int MAX_LETTER_NUMBER;
final int A_SMALL_CODE;
final int A_BIG_CODE;
final int MAX_LETTER_NUMBER_IN_LINE;
final int MAX_WORD_NUMBER;
final char DOT, COMMA, EXCLAMATION, QUESTION, DASH, COLON, QUOTES, SEMICOLON;

String[] Text;
int wordNum;

public Format() {
MAX_LETTER_NUMBER = 26;
A_SMALL_CODE = 97;
A_BIG_CODE = 65;
MAX_LETTER_NUMBER_IN_LINE = 20;
MAX_WORD_NUMBER = 200;
DOT = '.';
COMMA = ',';
QUESTION = '?';
DASH = '-';
COLON = ':';
QUOTES = '"';
EXCLAMATION = '!';
SEMICOLON = ';';
Text = new String[MAX_WORD_NUMBER];
wordNum = 0;
}

public boolean compareToPunct(char c) {
if (c == DOT || c == COMMA || c == QUESTION || c == DASH || c == COLON || c == QUOTES || c == EXCLAMATION || c == SEMICOLON) {
return true;
}
return false;
}

public void loadText(String fileName) throws IOException {
BufferedReader reader = new BufferedReader(new FileReader(fileName));
String s;
s = reader.readLine();
StringTokenizer st = new StringTokenizer(s);
wordNum = 0;
while (st.hasMoreTokens()) {
Text[wordNum] = st.nextToken();
wordNum++;
}
}

public void print() {
for (int i = 0; i < wordNum; i++)
System.out.println(Text[i]);
}
}
1 change: 1 addition & 0 deletions Format/myText.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Hello! My name is Kate. I'm a second year student of the Belarusian State University the Faculty of Applied Mathematics and Computer Science. I really engoy studying here.
11 changes: 11 additions & 0 deletions MyMain.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import Format.*;

import java.io.IOException;

public class MyMain {
public static void main(String[] args) throws IOException{
Format f = new Format();
f.loadText("C:\\Users\\Kate\\IdeaProjects\\program5\\src\\Format\\myText.txt");
f.print();
}
}

0 comments on commit c697f7d

Please sign in to comment.