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

Beyond Infinity : Organ Donation #26

Open
wants to merge 7 commits into
base: main
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
21 changes: 21 additions & 0 deletions Beyond Infinity : Organ Donation/Area.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

public class Area {
private String areaName;
private int areaCode;
public Area(String areaName, int areaCode) {
this.areaName = areaName;
this.areaCode = areaCode;
}
public String getAreaName() {
return areaName;
}
public void setAreaName(String areaName) {
this.areaName = areaName;
}
public int getAreaCode() {
return areaCode;
}
public void setAreaCode(int areaCode) {
this.areaCode = areaCode;
}
}
25 changes: 25 additions & 0 deletions Beyond Infinity : Organ Donation/City.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import java.util.*;
public class City {
private String cityname;
private int cityCode;
ArrayList<Area> lst;
public City(String cityname, int cityCode) {

this.cityname = cityname;
this.cityCode = cityCode;
lst = new ArrayList<>();
}
public String getCityname() {
return cityname;
}
public void setCityname(String cityname) {
this.cityname = cityname;
}
public int getCityCode() {
return cityCode;
}
public void setCityCode(int cityCode) {
this.cityCode = cityCode;
}

}
51 changes: 51 additions & 0 deletions Beyond Infinity : Organ Donation/DashBoard.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import java.util.Scanner;


//Main class
public class DashBoard {

public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc=new Scanner(System.in);
boolean exit = false;
while(!exit) {
System.out.println("\n----------WELCOME TO ORGAN TRANSPLANT CENTER----------");
System.out.println("1-Register as a donor");
System.out.println("2-Register as a receiver");
System.out.println("3-Login as a receiver");
int ch=sc.nextInt();
switch(ch){
case 1:
//take input info
//insert donor into db
//show nearest hospitals
Donor_info d1 = new Donor_info();
d1.AcceptInfo();

break;
case 2:
// Menu 1.See status
Receiver_info r1 = new Receiver_info();
r1.AcceptInfo();

break;
case 3:
System.out.println("\nEnter your name: ");
sc.nextLine();
String name = sc.nextLine();
System.out.println("Enter Your Mobile No.:");
long mob = sc.nextLong();
Receiver_info r = new Receiver_info();
r.Login(name, mob);
//display data of receiver
break;
default:
exit = true;
break;

}
}


}
}
120 changes: 120 additions & 0 deletions Beyond Infinity : Organ Donation/Donor.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Date;
import java.util.*;
public class Donor {


static final String JDBC_DRIVER = "com.mysql.cj.jdbc.Driver";
static final String DB_URL = "jdbc:mysql://localhost:3306/OrganDonation";
static final String USER = "root";
static final String PASS = "priyanka2240";
Connection con;


private String donorName;
private String donorBloodGroup;
private String birthDate;
private char gender;
private double weight;
private Area areaOfDonor;
private String organ;
private long contactNo;
ArrayList<Hospital> areawise_hospitals = new ArrayList<Hospital>();
public Donor(String donorName, String donorBloodGroup, String birthDate, char gender, double weight, String org,
Area areaOfDonor, long contactNo) {
this.donorName = donorName;
this.donorBloodGroup = donorBloodGroup;
this.birthDate = birthDate;
this.gender = gender;
this.weight = weight;
this.organ = org;
this.areaOfDonor = areaOfDonor;
this.contactNo = contactNo;


}
void area_hospitals(Donor d) { //pass donor area to this function
try {
/*String q = "select areaCode from Area where areaName = (?)";
PreparedStatement preparedStmt1;
preparedStmt1 = con.prepareStatement(q);
preparedStmt1.setString(1, d.getAreaOfDonor().getAreaName());
*/
con=DriverManager.getConnection(DB_URL,USER,PASS);
String query = "select * from Hospital where areaCode = ?;";
PreparedStatement preparedStmt1;
preparedStmt1 = con.prepareStatement(query);
preparedStmt1.setInt(1, d.getAreaOfDonor().getAreaCode());

ResultSet rs = preparedStmt1.executeQuery();

while(rs.next()) {
int h_code = rs.getInt("hospitalCode");
String h_name = rs.getString("hospitalName");
int area_code = rs.getInt("areaCode");
int city_code = rs.getInt("cityCode");
Hospital h = new Hospital(h_code,h_name,area_code,city_code);
d.areawise_hospitals.add(h);
}

}
catch(SQLException e) {
System.out.println("Not found");
e.printStackTrace();
}
}

public String getDonorName() {
return donorName;
}
public void setDonorName(String donorName) {
this.donorName = donorName;
}
public String getDonorBloodGroup() {
return donorBloodGroup;
}
public void setDonorBloodGroup(String donorBloodGroup) {
this.donorBloodGroup = donorBloodGroup;
}
public String getBirthDate() {
return birthDate;
}
public void setBirthDate(String birthDate) {
this.birthDate = birthDate;
}
public char getGender() {
return gender;
}
public void setGender(char gender) {
this.gender = gender;
}
public double getWeight() {
return weight;
}
public void setWeight(double weight) {
this.weight = weight;
}
public Area getAreaOfDonor() {
return areaOfDonor;
}
public String getorgan() {
return this.organ;
}
public void setAreaOfDonor(Area areaOfDonor) {
this.areaOfDonor = areaOfDonor;
}
public long getContactNo() {
return contactNo;
}
public void setContactNo(long contactNo) {
this.contactNo = contactNo;
}



}
Loading