日期:2014-05-20  浏览次数:20772 次

求助!“进行语法解析时已到达文件结尾”
import java.util.*;

class RegisterException extends Exception {

}

class Dosage extends Exception{

}

class Patient {
String name;
int id;

public void patient (String name, int id) throws RegisterException {
this.name = name;
this.id = id;

if(this.id == 0){
throw new RegisterException();
}
}

public void run(String name, int id) {
try{
patient(name,id);
} catch (RegisterException ex) {
System.out.println("您未挂号,请先挂号再看病!");
System.exit(0);
}
}
}

class Doctor {
String name;
int id;

public void Doctor(String name, int id) {
this.name = name;
this.id = id;
}

public void see() {
System.out.println(name+"医生为您确诊病症...");
}

public void Prescription() {
System.out.println(name+"医生为您开药方...");
}

}

class Pneumonia {
int d;

public void dosage(int d) throws Dosage {
this.d = d;

if(this.d<0 || this.d>32767){
throw new Dosage();
}

else {
System.out.println("请按量服药,祝您早日健康!^_^");
System.exit(0);
}
}

public void running(int d) {
try{
dosage(d);
}catch(Dosage ex) {
System.out.println("警告!警告!用药量错误!bi bu bi bu ... 这假冒医生是精神病院,来呀!给我绑回去喽!!!");
}
}
}

class BronchialPneumonia extends Pneumonia { //支气管肺炎

public void BronchialPneumonia() {
System.out.println("确诊为支气管肺炎!" );
}

public void dosage(int d) throws Dosage {
this.d = d;
if(this.d<40 || this.d>50) {
throw new Dosage();
}
else {
System.out.println("请按量服药,祝您早日健康!^_^");
System.exit(0);
}
}

class Streptococcuspneumoniae extends Pneumonia { //肺炎链球菌肺炎

public void Streptococcuspneumoniae() {
System.out.println( "确诊为链球菌肺炎!");
}

public void dosage(int d) throws Dosage {
this.d = d;
if(this.d<60 || this.d>100) {
throw new Dosage();
}
else {
System.out.println("请按量服药,祝您早日健康!^_^");
System.exit(0);
}
}
}

class StaphylococcusAureusPneumonia extends Pneumonia { //金黄色葡萄球菌肺炎

public void StaphylococcusAureusPneumonia() {
System.out.println("确诊为金黄色葡萄球菌肺炎!");
}

public void dosage(int d) throws Dosage {
this.d = d;
if(this.d<120 || this.d>160) {
throw new Dosage();
}
else {
System.out.println("请按量服药,祝您早日健康!^_^");
System.exit(0);
}
}
}

class Penicillin { //青霉素
//public void Penicillin() {}

public void using() {
System.out.println("使用青霉素");
}
}

public class KanBing {
public static void main(String[] args) {
String name;
int id;
int dosage;

System.out.println("请输入您的姓名和挂号!");
System.out.print("姓名:");
Scanner p1 = new Scanner(System.in);
name = p1.next();
System.out.print("挂号:");
Scanner p2 = new Scanner(System.in);
id = p2.nextInt();
Patient patient = new Patient();
patient.run(name,id);

System.out.println("请为您看病的医生的姓名和编号!");
System.out.print("姓名:");
Scanner d1 = new Scanner(System.in);
name = d1.next();
System.out.print("编号:");
Scanner d2 = new Scanner(System.in);
id = d2.nextInt();

Doctor doctor = new Doctor();
doctor.Doctor(name,id);
doctor.see();
BronchialPneumonia bp = new BronchialPneumonia(); //实例化一个支气管肺炎的对象