Patrick B. answered 11/15/20
Math and computer tutor/teacher
I have done most of the legwork for you...
I have given you the classes for the Employee, the Admin, the Doctor,
the Patient, the Service, and the Cross table...
YOU NEED TO BUILD FROM THERE...
There are a lot of design specifications that need
to be agreed upon and discussed.
You aren't allowed to input multiple patients but it's ok
to input mutiple Doctors and Admin Employees with the same
name?
Secondly, how are you supposed to check if the record is
a duplicate or not? Two patients CAN have the same name.
It is VERY possible and LEGAL!
The PATIENT ID # is what distinguishes the two records,
and makes EACH RECORD UNIQUE... REGARDLESS of the name
or anything else for that matter.
Are we supposed to be using a real database, or just
flat text files?
As far the exception goes, here is a sample program that
demonstrates how to create a custom exception, throw it,
and catch it. I have uploaded this source code in
the resources section for you.
If you attempt to input a duplicate integer in the array,
it throws the exception. This THE EXACT SAME THING you
are trying to do.
Send me an email so we can further discuss what is required.
These questions must be answered.
=====================================================
import java.lang.RuntimeException;
class CustExTest
{
class DuplicateIDException extends RuntimeException
{
//private or protected data members may be the
//data that caused the exception, invalid entires, etc
DuplicateIDException(String errMsg)
{
super(errMsg);
}
}
public static void main(String args[])
{
int A[]={1,3,5,7,9}; //duplicates not allowed
CustExTest x = new CustExTest();
int n=4;
try
{
int [] _A = x.AddNew(A,n);
if (_A!=null) { System.out.println("Successfully added " + n); }
n=7;
A = x.AddNew(_A,n);//this one will throw the exception
if (A!=null) { System.out.println("Successfully added " + n); }
}
catch (DuplicateIDException ex)
{
System.out.println("Exception occurs: input is "+n);
}
}
//Inserts x at the end of array A; if x is already in A, then throws exception;
//If x is already in A, returns null; otherwise returns the array
public int [] AddNew(int A[], int x) throws DuplicateIDException
{
int [] AReturn=null;
int N=A.length;
boolean found_flag=false;
for (int iLoop=0; iLoop<N; iLoop++)
{
if (A[iLoop]==x)
{
found_flag=true;
break;
}
}
if (!found_flag)
{
//copies
N = A.length;
AReturn = new int[N+1];
for (int iLoop=0; iLoop<N; iLoop++)
{
AReturn[iLoop]=A[iLoop];
}
AReturn[N]=x;
}
else
{
AReturn=null;
String strCulprit = "input = "+x;
throw ( new DuplicateIDException(strCulprit));
}
return(AReturn);
}
}
NAD M.
Thanks, but this is not i need exactly11/15/20