How to write this driver class, java?

Jason M

New member
Programming project: Design and implement a program that counts the number of punctuation marks in a text input file. Produce a table that show how many times each symbol occurred. Use the following list of punctuation marks: , : ; . ! - ' " ? / \
Make sure that your program has two classes, one for counting punctuations and the other a driver/test class that uses the other class.

Ok, so I got my class done and the code looks like this:

import java.io.*;

import java.awt.*;

import java.util.*;

import javax.swing.*;

import java.awt.event.*;

public class PunctuationCounter extends JFrame implements ActionListener {

private JButton read = new JButton("Read & Count Punctuations");

private JTextField getFileName = new JTextField(20);

private JTextArea fileArea = new JTextArea();

private JScrollPane pane = new JScrollPane(fileArea);

private JPanel nPanel = new JPanel();

private Container content;

public PunctuationCounter() {

super("Punctuation Counter");

content = getContentPane();

setSize (350,400);

getFileName.setForeground (Color.blue );

fileArea.setBackground (Color.black);

fileArea.setForeground (Color.red );

fileArea.setFont (new Font("Times New Roman", Font.BOLD, 20));

nPanel.setLayout (new BorderLayout());

nPanel.add (getFileName, BorderLayout.CENTER);

nPanel.add (read, BorderLayout.WEST);

content.add (nPanel, BorderLayout.NORTH);

content.add (pane);

read.addActionListener (this);

addWindowListener(new WindowAdapter() {

public void windowClosing(WindowEvent e) {

System.exit(0);

}

}

);

}

public void actionPerformed (ActionEvent evt) {

read();

}

private final static int COMMA = 0;

private final static int PERIOD = 1;

private final static int QUESTION = 2;

private final static int BANG = 3;

private final static int SEMI = 4;

private final static int COLON = 5;

private final String punctuations = ",.?!;:";

private void read () {

int[] cc = new int[]

{

0, //,

0, //.

0, //?

0, //!

0, //;

0 //:

};

int count = 0;

String punct;

StringTokenizer tokenizer;

String fileName = getFileName.getText().trim();

But I have no idea about writing the driver class. Can anyone help me out with writing the driver class?
 
Back
Top