Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

class 10 implementation #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions Class 10/Hospital.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import model.*;
import java.util.*;
public class Hospital{

public static void main(String[] args)
{
Date doctor1date = new Date("1970/11/21");
Date doctor2date = new Date("1970/11/21");
Doctor doctor1 = new Neurologist("Jon",454,doctor1date,"AB+","as23-12","neurologist",false);
Doctor doctor2 = new Doctor("Simon",256,doctor2date,"AB+","ab67-12","general doctor",true);

ArrayList <Doctor> doctors = new ArrayList<>();
doctors.add(doctor1);
doctors.add(doctor2);

Patient patient1 = new Patient();
Patient patient2 = new Patient();
Patient patient3 = new Patient();

ArrayList<Patient> patients = new ArrayList<>();
patients.add(patient1);
patients.add(patient2);
patients.add(patient3);

for(int i=0;i<doctors.size();i++)
{
System.out.println("Available doctors: " + doctors.get(i).getName() + " " + doctors.get(i).getSpeciality());
for(int j=0;j<patients.size();j++){
if(doctors.get(i).isGeneralDoctor())
{
doctors.get(i).examine(patients.get(j));
}
}
}

Date mydate = new Date("1995/12/21");
Person person1 = new Person("Sara",123,mydate,"A+");
Date mydate2 = new Date("1997/09/21");
Person person2 = new Person("Emily",123,mydate2,"AB+");
Date mydate3 = new Date("2003/09/21");
Person person3 = new Person("Alex",123,mydate3,"AB+");

ArrayList<Person> people = new ArrayList<>();
people.add(person1);
people.add(person2);
people.add(person3);

ArrayList <Patient> nonRegistered = new ArrayList<>();
int k=0;
for(int i=0;i<patients.size();i++)
{

if( patients.get(i).isEmergency() )
{
System.out.println("patient number " + i + " is sent to the specialist");
nonRegistered.add(patients.get(i));
}
else if ( patients.get(i).toBeRegistered() )
{
System.out.println("normal patient at " + i );
patients.get(i).setPerson(people.get(i));
k++;

}
else
{
System.out.println("patient number " + i + " is checkup patient! ");
patients.get(i).setPerson(people.get(i));
k++;
}
}
System.out.println("Non-Registered Patients are " + nonRegistered.size() );
System.out.println("Registered Patients are " + k);
for(int i=0;i<patients.size();i++)
{
if(patients.get(i).getPerson().getName()!=null){
System.out.println(patients.get(i).getPerson().getName());
}
}


}

}
74 changes: 74 additions & 0 deletions Class 10/model/Doctor.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package model;
import java.util.*;
public class Doctor extends Person
{
private String medicDoctorLicence;
private String speciality;
private boolean generalDoctor;

public Doctor(String name,int number,Date dateOfBirth,String bloodType,String medicDoctorLicence,String speciality,boolean generalDoctor)
{
super(name,number,dateOfBirth,bloodType);
this.medicDoctorLicence = medicDoctorLicence;
this.speciality = speciality;
this.generalDoctor = generalDoctor;
}
public boolean isGeneralDoctor()
{
return generalDoctor;
}
public void setSpeciality(String speciality)
{
this.speciality = speciality;
}
public void setLicence(String medicDoctorLicence)
{
this.medicDoctorLicence = medicDoctorLicence;
}
public String getSpeciality()
{
return speciality;
}
public String getMedicDoctorLicence()
{
return medicDoctorLicence;
}
public void examine(Patient patient)
{

Random random = new Random();
int a = random.nextInt(4);

/* if(patient.getIllness().equals("brain"))
{
patient.setPriority(true,false,false);
}
else{
patient.setPriority(false,false,true);
}*/

if( a == 1) //<- Randomized check
{
patient.setPriority(true,false,false);
}
else if( a == 2)
{
patient.setPriority(false,true,false);
}
else
{
patient.setPriority(false,false,true);
}
}
public void setExitDate(Patient patient)
{
Date date = new Date();
Random random = new Random();
int rMonth = random.nextInt((12-date.getMonth()+1)) + date.getMonth();
int rDay = random.nextInt((30-date.getDay()+1)) + date.getDay();
String dateR = date.getYear() + "/" + rMonth + "/" + rDay;
Date releaseDate = new Date(dateR);
patient.setExitDate(releaseDate);
}

}
12 changes: 12 additions & 0 deletions Class 10/model/Neurologist.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

package model;
import java.util.*;

public class Neurologist extends Doctor
{
public Neurologist(String name,int number,Date dateOfBirth,String bloodType,String medicDoctorLicence,String speciality,boolean generalDoctor)
{
super(name,number,dateOfBirth,bloodType,medicDoctorLicence,speciality,generalDoctor);
}

}
76 changes: 76 additions & 0 deletions Class 10/model/Patient.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
package model;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*;

public class Patient
{
Person person;
protected boolean registeration;
protected boolean emergency;
protected boolean checkup;
protected Date exitDate;
protected String myIllness ;
protected String[] illness = {"brain","cancer"};
public Patient()
{
registeration = false;
emergency = false;
checkup = false;
Random myRandom = new Random();
myIllness = illness[myRandom.nextInt(illness.length)];
}
public String getIllness() // get illness hahahaha
{
return myIllness;
}
public void setPriority(boolean registration,boolean emergency,boolean checkup)
{
this.registeration = registeration;
this.emergency = emergency;
this.checkup = checkup;
person = new Person();
}
public Person getPerson()
{
return person;
}
public void setPerson(Person person)
{
this.person.copyPerson(person);
}
public Patient(boolean registration , boolean emergency , boolean checkup)
{
if(registeration && emergency && checkup)
{
System.out.println("can't create a patient!");
}
else
{
this.registeration = registeration;
this.emergency = emergency;
this.checkup = checkup;
}
}
public boolean toBeRegistered()
{
return registeration;
}
public boolean isEmergency()
{
return emergency;
}
public boolean isCheckUp()
{
return checkup;
}
public void setExitDate(Date exitDate)
{
this.exitDate = exitDate;
}
public Date getExitDate()
{
return exitDate;
}

}
63 changes: 63 additions & 0 deletions Class 10/model/Person.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package model;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Person
{
protected String name;
protected int number;
protected Date dateOfBirth;
protected String bloodType;
public Person(String name,int number,Date dateOfBirth,String bloodType)
{
this.name = name;
this.number = number;
this.dateOfBirth = dateOfBirth;
this.bloodType = bloodType;
}
public Person()
{

}
public String getName()
{
return name;
}
public int getNumber()
{
return number;
}
public Date getDateOfBirth()
{
return dateOfBirth;
}
public String getBloodType()
{
return bloodType;
}

public void setName(String name)
{
this.name = name;
}
public void getNumber(int number)
{
this.number = number;
}
public void getDateOfBirth(Date dateOfBirth)
{
this.dateOfBirth = dateOfBirth;
}
public void setBloodType(String bloodType)
{
this.bloodType = bloodType;
}
public void copyPerson(Person person)
{
this.name = person.name;
this.number = person.number;
this.dateOfBirth = person.dateOfBirth;
this.bloodType = person.bloodType;
}
}