使用字符串和子菜单打印报告

时间:2015-09-07 00:44:30

标签: java arrays string report text-files

我需要一些帮助来完成我的程序。我已将其设置为列出6个选项。选项2和3应该打开自己的4个选项列表。现在,当我选择2或3时,它会打开正确的选项,但如果我尝试选择其中一个后续报告,它只会将我踢回主菜单。我的问题是,这是他们改变我的代码以使其按照我想要的方式工作的方法,或者我应该使用命令行,无论哪种方式我都可以使用它,因为我彻底难倒。非常感谢任何帮助。

  

错误消息:Patient_Reports中的doctorMain(String [])不能   适用于()

     

错误消息位于我的主要方法

中      

编译器错误消息:错误:(30,24)java:方法doctorMain in   class Test.Patient_Reports不能应用于给定的类型;
  required:java.lang.String []找到:无参数原因:   实际和正式的参数列表长度不同

Data File (patient.txt):  
    11111,Smith,Norris,Thyroid,1000.00
    11112,Obama,Norris,Lasek,500.00
    11113,Hoover,Norris,Dental,100.00
    11114,Cena,Norris,Lasek,500.00
    11115,Leto,Norris,Thyroid,1000.00
    22221,Clark,Bond,Thyroid,1000.00
    22222,Chang,Bond,Lasek,500.00
    22223,Dent,Bond,Dental,100.00
    22224,Nixon,Bond,Lasek,500.00
    22225,Washington,Bond,Dental,100.00
    33331,Jones,Lee,Dental,100.00
    33332,Ross,Lee,Lasek,500.00
    33333,Gates,Lee,Thyroid,1000.00
    33334,Johnson,Lee,Thyroid,1000.00
    33335,Carter,Lee,Dental,100.00  

该计划的简明版本 计划:(班级为Patient_Reports)

    package Test;

    /**
    * Created by Brandon on 9/6/2015.
    */
    import javax.swing.*;
    import java.io.*;
    import java.util.*;
    public class Patient_Reports {

    private final int[] id = new int[100];
    private final String[] patient = new String[100];
    private final String[] doctor = new String[100];
    private final String[] surgery = new String[100];
    private final double[] cost = new double[100];
    private int count = -1;
    private int i;

    //Main Method
    public static void main(String[] args) {
        int selection;
        String report_number;
        Patient_Reports patient = new Patient_Reports();
        patient.start_system();
        report_number = patient.menu();
        selection = Integer.parseInt(report_number);
        while (selection != 2) {
            if (selection == 1) {
                patient.surgeryDoctorMenu();
                patient.doctorMain();  <<<<<<<<<< error message is here        
            }
            report_number = patient.menu();
            selection = Integer.parseInt(report_number);
        }//While Loop
        patient.writeReports();
        System.exit(0);
    }//End Main

    //Read Data File into Array
    private void start_system() {
        String newLine;
        try {
            //Read text file into an array.
            BufferedReader Patient_Reports = new BufferedReader(new FileReader("patient.txt"));
            while ((newLine = Patient_Reports.readLine()) != null) {
                //Comma Delimited
                StringTokenizer delimiter = new StringTokenizer(newLine, ",");
                count = count + 1;
                id[count] = Integer.parseInt(delimiter.nextToken());
                patient[count] = delimiter.nextToken();
                doctor[count] = delimiter.nextToken();
                surgery[count] = delimiter.nextToken();
                cost[count] = Double.parseDouble(delimiter.nextToken());
            }//While Loop
            Patient_Reports.close();
        }//End Try
        catch (IOException error) {
            //Error in File Writing
            System.out.println("Error on file read " + error);
        }//End Catch
    }//End start_system

    //Report Menu
    private String menu() {
        String report;
        String Output = "Reports:" + "\n" + "1. Surgeries Doctor Report" + "\n" +
                "2. Exit" + "\n" +
                " " + "\n" +
                "Select a Report >";
        report = JOptionPane.showInputDialog(null,
                Output, "", JOptionPane.QUESTION_MESSAGE);
        return report;
    }//End Menu

    //Store Data File in Array
    private void writeReports() {
        try {
            BufferedWriter Patient_Reports = new BufferedWriter(new FileWriter("patient_out.txt"));
            for (i = 0; i <= count; ++i) {
                //Comma Delimit
                Patient_Reports.write(id[i] + "," + patient[i] + "," + doctor[i] + "," +
                        surgery[i] + "," + cost[i] + ",");
                //Write a new line in patient_out.txt
                Patient_Reports.newLine();
            }//End For Loop
            Patient_Reports.close();
        }//End Try
        catch (IOException error) {
            //Error on Write to File
            System.out.println("Error on file write " + error);
        }//End Error
    }//End writeReports

    //Main for Doctor Reports
    public static void doctorMain (String[] args) {
        int doctor_selection;
        String doctor_name;
        Patient_Reports doctor = new Patient_Reports();
        doctor.start_system();
        doctor_name = doctor.surgeryDoctorMenu();
        doctor_selection = Integer.parseInt(doctor_name);
        while (doctor_selection !=2) {
            if (doctor_selection == 1) {
                doctor.norrisSurgeries();
            } 
            doctor_name = doctor.surgeryDoctorMenu();
            doctor_selection = Integer.parseInt(doctor_name);
        }//While Loop
    }//End doctorMain

    //Report on all surgeries of a specific doctor (prompt for the doctor)
    //Report Menu
    private String surgeryDoctorMenu() {
        System.out.println("Surgeries Doctor Report:");
        String doctor_report;
        String Output = "Surgery Doctor Reports:" + "\n" + "1. Norris Surgeries Report" + "\n" +
                "2. Bond Surgeries Report" + "\n" +
                "3. Lee Surgeries Report" + "\n" +
                "4. Exit" + "\n" +
                " " + "\n" +
                "Select a Report >";
        doctor_report = JOptionPane.showInputDialog(null,
                Output, "", JOptionPane.QUESTION_MESSAGE);
        return doctor_report;
    }//end menu\

    //Report on all surgeries by Dr. Norris
    private void norrisSurgeries() {
        System.out.println("Norris Surgeries Report:");
        System.out.println("5" + " ");
    }//End norrisSurgeries
}

0 个答案:

没有答案