⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 test4_listofpatients.java

📁 A system to manage patients of an hospital (using Inheritance, Exceptions and Collections).
💻 JAVA
字号:
import java.util.Collection;import java.util.Iterator;import junit.framework.TestCase;import hospital.*;public class Test4_ListOfPatients extends TestCase {	public Test4_ListOfPatients(String name) {		super(name);	}	Hospital h;		protected void setUp() throws Exception {		h = new Hospital();	}	public void testList() throws NoSuchPatient, NoSuchDoctor {			String ssn1 = "THEPID12I99F181K";			h.addPatient("Giova","Reds", ssn1);			String ssn2 = "BLKSRS11I88F981K";			h.addPatient("Sirius","Black", ssn2);			int docID = 5;			String dfirst = "Mario";			String dlast = "White";			h.addDoctor(dfirst, dlast, docID);						h.assignPatientToDoctor(ssn1, docID);			h.assignPatientToDoctor(ssn2, docID);						Person p1 = h.getPatient(ssn1);			Person p2 = h.getPatient(ssn2);									Collection patients = h.getDoctor(docID).getPatients();					    assertTrue(patients.contains(p1));			assertTrue(patients.contains(p2));	  }	  	  public void testOrderedList() throws NoSuchPatient, NoSuchDoctor {			String ssn1 = "THEPID12I99F181K";			h.addPatient("Giova","Red", ssn1);			String ssn2 = "BLKSRS11I88F981K";			h.addPatient("Sirius","Black", ssn2);			String ssn3 = "RSSPLA13I88F981K";			h.addPatient("Paolo","White", ssn3);			int docID = 5;			String dfirst = "Mario";			String dlast = "White";			h.addDoctor(dfirst, dlast, docID);			h.assignPatientToDoctor(ssn1, docID);			h.assignPatientToDoctor(ssn2, docID);			h.assignPatientToDoctor(ssn3, docID);						Collection patients = h.getDoctor(docID).getPatients();			Iterator it = patients.iterator();				  		Person p1 = (Person)it.next();			Person p2 = (Person)it.next();			Person p3 = (Person)it.next();						assertEquals("Red",p1.getLast());			assertEquals("Black",p2.getLast());			assertEquals("White",p3.getLast());			assertEquals("Paolo",p3.getFirst());	  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -