{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# sol6 - 1.124J Foundations of Software Engineering Problem...

This preview shows pages 1–6. Sign up to view the full content.

1.124J Foundations of Software Engineering Problem Set 6 - Solution Due Date: Thursday 11/2/00 Problem 1:[60%] Part A: Sol6_1.java public class Sol6_1a { public static void main(String args[]) { new Plotter1(); } } plotter.java import java.io.*; import java.util.*; public class Plotter1 { Plotter1() { readData(); } void readData() {

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
FileInputStream ifp; double x[], y[]; x = y = null; String fileName = new String("data6_1"); try{ ifp = new FileInputStream(fileName); } catch(FileNotFoundException e) { System.out.println(" File " + fileName + " was not found."); return; } int i, n=0; InputStreamReader rd = new InputStreamReader(ifp); StreamTokenizer tk = new StreamTokenizer(rd); try { tk.nextToken(); n = (int)tk.nval; x = new double[n]; y = new double[n]; for(i=0;i<n;i++) { tk.nextToken(); x[i] = (double)tk.nval; tk.nextToken(); y[i] = (double)tk.nval; } ifp.close(); } catch(IOException e) { System.out.println("IOException: " + e.getMessage()); } System.out.println("\n" + n + " points have been read"); for(i=0;i<n;i++) { System.out.print("x[" + (i+1) +"]=" + x[i]);
System.out.println("\ty[" + (i+1) +"]=" + x[i]); } } } Part B: Sol6_1.java public class Sol6_1 { public static void main(String args[]) { new Plotter(); } } plotter.java import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.io.*; import java.util.*; public class Plotter extends JFrame implements ActionListener { private JMenuBar menuBar ; private JMenu fileMenu; private JMenuItem importMI, exitMI; private JToolBar toolBar = new JToolBar(); private JButton dashedButton, solidButton; private JPanel contentPane; private Plot plot;

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
setJMenuBar(menuBar); } private void setToolBar() { toolBar = new JToolBar(); dashedButton = new JButton(new ImageIcon("dashed.gif")); dashedButton.setMnemonic(KeyEvent.VK_D); dashedButton.setToolTipText("Dashed line"); dashedButton.addActionListener(this);

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 15

sol6 - 1.124J Foundations of Software Engineering Problem...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online