Java 使用带有子菜单的字符串';s打印报告
我需要一些帮助来完成我的程序。我已将其设置为列出6个选项。选项2和3应该打开自己的4个选项列表。现在,当我选择2或3时,它会打开他们应该打开的正确选项,但如果我尝试并选择他们的后续报告之一,它只会将我踢回主菜单。我的问题是,这是一种改变我的代码的方法,以使它以我想要的方式工作,或者我应该使用命令行,无论哪种方式,我都可以使用一些帮助,因为我完全被难倒了。非常感谢您的帮助 错误消息:无法删除患者报告中的doctorMain(字符串[]) 适用于() 错误消息位于我的主方法中 编译器错误消息:错误:(30,24)java:method doctorMain in in 类Test.Patient_报告不能应用于给定类型Java 使用带有子菜单的字符串';s打印报告,java,arrays,string,report,text-files,Java,Arrays,String,Report,Text Files,我需要一些帮助来完成我的程序。我已将其设置为列出6个选项。选项2和3应该打开自己的4个选项列表。现在,当我选择2或3时,它会打开他们应该打开的正确选项,但如果我尝试并选择他们的后续报告之一,它只会将我踢回主菜单。我的问题是,这是一种改变我的代码的方法,以使它以我想要的方式工作,或者我应该使用命令行,无论哪种方式,我都可以使用一些帮助,因为我完全被难倒了。非常感谢您的帮助 错误消息:无法删除患者报告中的doctorMain(字符串[]) 适用于() 错误消息位于我的主方法中 编译器错误消息:错误:
必需:java.lang.String[]找到:无参数原因: 实际参数列表和形式参数列表的长度不同 程序的浓缩版本
课程:(课程为患者报告)
封装测试;
/**
*布兰登于2015年6月9日创作。
*/
导入javax.swing.*;
导入java.io.*;
导入java.util.*;
公共类病人报告{
私有最终整数[]id=新整数[100];
私有最终字符串[]患者=新字符串[100];
私有最终字符串[]医生=新字符串[100];
私有最终字符串[]外科手术=新字符串[100];
私人最终双倍[]成本=新双倍[100];
私有整数计数=-1;
私人互联网i;
//主要方法
公共静态void main(字符串[]args){
int选择;
字符串报告编号;
患者报告患者=新患者报告();
病人。启动系统();
报告编号=patient.menu();
selection=Integer.parseInt(报告编号);
while(选择!=2){
如果(选择==1){
患者。手术医生菜单();
patient.doctorMain();请创建。我们会更容易帮助您,您也会更容易找到我们的答案。在创建这样的示例时,您也有可能解决自己的问题,因此值得花一些时间在上面。老实说,当您按[2]键调用patient.surgeryDoctorMenu时,我不确定您希望看到什么();
它显示一个菜单并返回用户选择的选项,但您对它不做任何操作,按[3]时也会发生同样的情况我压缩了代码以更好地显示问题。也许我只是不知道如何操作,但我希望子级别显示我的报告。例如,在压缩版本中,如果您运行它。我希望能够选择手术医生报告,然后选择Norris手术报告并让它显示报告。请创建。这样我们可以更轻松地创建帮助您,您将更容易找到我们的答案。在创建这样的示例时,您也有可能解决自己的问题,因此值得花一些时间在上面。老实说,当您按[2]调用patient.surgeryDoctorMenu()时,我不确定您希望看到什么;
它显示一个菜单,并返回用户选择的选项,但您不使用它,按[3]时也会发生同样的情况我压缩代码以更好地显示问题。也许我只是不知道如何操作,但我希望子级别显示我的报告。例如,在压缩版本中,如果您运行它。我希望能够选择手术医生报告,然后选择Norris手术报告并让它显示报告。
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
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
}