Wa0031.

Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

MR.

COOPER ROUND II

Problem Statement:

ER Diagram (Not fully completed):

Implementation Code (Not fully completed):

// importing required packages


import java.io.*;
import java.util.*;

class User{
String userEmail;
String userName;
int zoneId;
int streetId;

User(String email, String name, int zoneId, int streetId){


this.userEmail = email;
this.userName = name;
this.zoneId = zoneId;
this.streetId = streetId;
}

public String toString(){


return "[ userEmail: "+ this.userEmail + ", userName:
"+ this.userName+ ", zoneId: "+ this.zoneId + ", streetId: "+
this.streetId +" ]";
}
}

class Zone{
static int count = 0;
int zoneId;
//private int activeCases;
int activeCases;
int recoveredCases;
int deceasedCases;

Zone(){
zoneId = ++count;
activeCases = 0;
recoveredCases = 0;
deceasedCases = 0;
}

public String toString(){


return "[ zoneId: "+ this.zoneId + ", activeCases: "+
this.activeCases+ ", recoveredCases: "+ this.recoveredCases +
", deceasedCases: "+ this.deceasedCases +"]";
}
}
class Street{
static int count = 0;
int streetId;
int zoneId;
String name;

Street(int zoneId, String name){


this.streetId = ++count;
this.zoneId = zoneId;
this.name = name;
}

public String toString(){


return "[ zoneId: "+ this.zoneId + ", streetId: "+
this.streetId+ ", name: "+ this.name+"]";
}
}

class Hospital{
static int count = 0;
int hospitalId;
String hospitalName;
boolean isCovidFacilities;
int zoneId;

Hospital(String hospitalName, boolean isCovidFacilities,


int zoneId){
this.hospitalId = ++count;
this.hospitalName = hospitalName;
this.isCovidFacilities = isCovidFacilities;
this.zoneId = zoneId;
}

public String toString(){


return "[ zoneId: "+ this.zoneId + ", hospitalId: "+
this.hospitalId+ ", name: "+ this.hospitalName+",
isCovidFacilities: "+isCovidFacilities+"]";
}
}

class TestData{
static int count;
int requestId;
String userEmail;
int hospitalId;
boolean isInHome;
boolean isDone;
boolean isPositive;

TestData(String userEmail, int hospitalId, boolean


isInHome){
this.requestId = ++count;
this.userEmail = userEmail;
this.hospitalId = hospitalId;
this.isInHome = isInHome;
this.isDone = false;
this.isPositive = false;
}

public String toString(){


return "[ requestId: "+ requestId +", userEmail: "+
this.userEmail + ", hospitalId: "+ this.hospitalId+ ",
isInHome: "+ this.isInHome + ", isDone: "+ this.isDone +",
isPositive; "+ isPositive+"]";
}
}

class Range{
int rangeId;
int redZoneRange;
int orangeZoneRange;
//int greenZoneRange;

Range(){
redZoneRange = 50;
orangeZoneRange = 10;
//greenZoneRange =
}
}

class CovidHelper{
public static void main(String[] args){
System.out.println("\n\nWelcome to Covid Helper :)");

// sample inputs

//zone
System.out.println("Creating zones...");
ArrayList<Zone> zoneList = new ArrayList<Zone>();
for(int i=1; i<=5; i++){
zoneList.add(new Zone());
}
for(int i=0; i<5; i++){
System.out.println(zoneList.get(i));
}
System.out.println("Zones created...");

//streets
System.out.println("Creating streets inside
zones...");
ArrayList<Street> streetList = new
ArrayList<Street>();
char s_name ='A';
for(int i=0; i<5; i++){
for(int j=0; j<2; j++){
streetList.add(new Street(i, s_name +
""+s_name));
s_name++;
}
}

for(Street s: streetList){
System.out.println(s);
}
System.out.println("Creating hospitals inside
zones...");
ArrayList<Hospital> hospitalList = new
ArrayList<Hospital>();
char h_name ='a';
boolean temp = true;
int x=1;
for(Zone z: zoneList){
hospitalList.add(new Hospital(h_name + ""+h_name,
temp, x++ ));
h_name++;
temp = !temp;
}
for(Hospital h: hospitalList){
System.out.println(h);
}
System.out.println("Hospitals Created...");

// users

System.out.println("Creating users inside streets in


zones...");

ArrayList<User> userList= new ArrayList<User>();


char u_name = 'a';
String _u_email ="[email protected]";
char u_email = 'a';

for(Street s: streetList){
for(int i=0; i<2; i++){
userList.add(new User(u_email+""+_u_email,
u_name +""+u_name, s.zoneId, s.streetId));
u_name++;
u_email++;
}
}
for(User u: userList){
System.out.println(u);
}
System.out.println("Users created");

// Test data
System.out.println("Creating test data");

ArrayList<TestData> testDataList= new


ArrayList<TestData>();
int startHospitalId = 1;
boolean home = true;

for(int i=1; i<=userList.size(); i+=2){


testDataList.add(new
TestData(userList.get(i).userEmail, startHospitalId++,home));
home = !home;
if(startHospitalId> hospitalList.size()){
startHospitalId = 1;
}
}

for(TestData td: testDataList){


System.out.println(td);
}

System.out.println("Test data created...");


}
}

Name : Kartheeswaran S

Roll Number : 171CS172

Phone : 9566545006

Email : [email protected]

You might also like