博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
12-29打印病历单(函数的继承)
阅读量:6120 次
发布时间:2019-06-21

本文共 4742 字,大约阅读时间需要 15 分钟。

hot3.png

Medical.java
public class Medical {	private String name;	private boolean eType;	private boolean nType;	private double price;	private int dTime;	private int num;	private boolean lOrB;		public Medical(String name,boolean eType,boolean nType,double price,int dTime,int num,boolean lOrB){		this.name=name;		this.eType=eType;		this.nType=nType;		this.price=price;		this.dTime=dTime;		this.num=num;		this.lOrB=lOrB;	}		public String getInfo(){		String eStr="外用";		String nStr="中药";		if(eType){			eStr="内服";		}		if(nType){			nStr="西药";		}		return "\n名          称:"+name+		       "\n服用类型:"+eStr+		       "\n品种类型:"+nStr+		       "\n单          价:"+price+		       "\n服用方案:"+eMethod()+		       "\n-------------------------------";	}		public String eMethod(){		String eMStr="粒";		if(lOrB){			eMStr="包";		}		return "一日"+dTime+"次,每次"+num+eMStr;	}	public String getName() {		return name;	}	public void setName(String name) {		this.name = name;	}	public boolean iseType() {		return eType;	}	public void seteType(boolean eType) {		this.eType = eType;	}	public boolean isnType() {		return nType;	}	public void setnType(boolean nType) {		this.nType = nType;	}	public double getPrice() {		return price;	}	public void setPrice(double price) {		this.price = price;	}	public int getdTime() {		return dTime;	}	public void setdTime(int dTime) {		this.dTime = dTime;	}	public int getNum() {		return num;	}	public void setNum(int num) {		this.num = num;	}	public boolean islOrB() {		return lOrB;	}	public void setlOrB(boolean lOrB) {		this.lOrB = lOrB;	}		}

 

CHistory.java

import java.util.GregorianCalendar;public class CHistory {		private String name;	private int age;	private boolean sex;	private String tOffice;	private GregorianCalendar gc;	private Medical[] medical;		public CHistory(String name,int age,boolean sex,String tOffice,GregorianCalendar gc,Medical[] medical){		this.name=name;		this.age=age;		this.sex=sex;		this.tOffice=tOffice;		this.gc=gc;		this.medical=medical;	}		public String getInfo(){		String str="女";		if(sex){			str="男";		}		return "姓          名:"+name+		       "\n年          龄:"+age+		       "\n性          别:"+str+		       "\n科          室:"+tOffice+		       "\n病历建立时间:"+gc.getTime().toLocaleString()+		       "\n所用药品:"+		       "\n==============================="+		       uMedical();		       	}		public String uMedical(){		String uStr="";		for(int i=0;i

Ophthalmology.java

import java.util.GregorianCalendar;public class Ophthalmology extends CHistory{		private double oDPrice;	public Ophthalmology(String name, int age, boolean sex, String tOffice,			GregorianCalendar gc, Medical[] medical,double oDPrice) {		super(name, age, sex, tOffice, gc, medical);		// TODO Auto-generated constructor stub		this.oDPrice=oDPrice;	}		public String getInfo(){		return super.getInfo()+		             "\n眼科门诊费用:"+oDPrice+		             "\n眼科治疗费用:"+oPrice()+	                 "\n*******************************";	}		public double oPrice(){		return oDPrice+super.uPrice();	}	public double getoDPrice() {		return oDPrice;	}	public void setoDPrice(double oDPrice) {		this.oDPrice = oDPrice;	}		}

 

Surgery.java

import java.util.GregorianCalendar;public class Surgery extends CHistory{	private double sDPrice;	private double oPrice;		public Surgery(String name, int age, boolean sex, String tOffice,			GregorianCalendar gc, Medical[] medical,double sDPrice,double oPrice) {		super(name, age, sex, tOffice, gc, medical);		// TODO Auto-generated constructor stub		this.sDPrice=sDPrice;		this.oPrice=oPrice;	}		public String getInfo(){		return super.getInfo()+		             "\n外科门诊费用:"+sDPrice+		             "\n手术          费用:"+oPrice+		             "\n外科治疗费用:"+sPrice()+		             "\n*******************************";	}		public double sPrice(){		return super.uPrice()+sDPrice+oPrice;	}	public double getsDPrice() {		return sDPrice;	}	public void setsDPrice(double sDPrice) {		this.sDPrice = sDPrice;	}	public double getoPrice() {		return oPrice;	}	public void setoPrice(double oPrice) {		this.oPrice = oPrice;	}		}

 

Test.java

 

package P1229;

import java.util.GregorianCalendar;

public class Test {

 /**   * @param args   */  public static void main(String[] args) {   // TODO Auto-generated method stub

  Medical[] mc1={new Medical("白加黑",true,true,20.0,3,2,true),new Medical("白加黑",true,true,20.0,3,2,true)};   Ophthalmology op=new Ophthalmology("赵四",22,true,"眼科",new GregorianCalendar(2012,12,28),mc1,500);      Medical[] mc2={new Medical("感康",true,true,20.0,2,1,false),new Medical("感康",true,true,20.0,3,1,false)};   Surgery sg=new Surgery("刘能",22,true,"眼科",new GregorianCalendar(2012,12,28),mc2,500,200);      CHistory[] cs=new CHistory[2];   cs[0]=op;   cs[1]=sg;      for(int i=0;i<cs.length;i++){    System.out.println(cs[i].getInfo());   }     }

}

 

 

转载于:https://my.oschina.net/1028528280/blog/99026

你可能感兴趣的文章
体重档案应用客户端源码
查看>>
在linux中添加ftp用户,以及修改FTP默认端口号
查看>>
N26-第一周作业
查看>>
4月11日中高项作业
查看>>
华为交换机AAA特性与思科ACS对接
查看>>
二:Unit 8
查看>>
TortoiseSVN客户端重新设置用户名和密码
查看>>
nagios邮件报警配置
查看>>
Java 生产条形码代码
查看>>
python web开发-flask连接sqlite数据库
查看>>
Zxing二维码扫描
查看>>
MMU的作用
查看>>
Ubuntu环境下 matplotlib 图例中文乱码
查看>>
PostgreSQL--杀死已挂掉的连接
查看>>
决心书
查看>>
sendmail 安装配置与使用
查看>>
文件描述符和df的一个有趣的问题
查看>>
01月09日 四周二次
查看>>
计算机网络(2)
查看>>
14.4-14.5 NFS的exportfs命令,NFS客户端问题
查看>>