init commit
- Campaign, Pilgrim and enums - Project files
This commit is contained in:
commit
50fcd50693
3
.idea/.gitignore
vendored
Normal file
3
.idea/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
6
.idea/misc.xml
Normal file
6
.idea/misc.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||||
|
<output url="file://$PROJECT_DIR$/out" />
|
||||||
|
</component>
|
||||||
|
</project>
|
8
.idea/modules.xml
Normal file
8
.idea/modules.xml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/Hajj-simulation.iml" filepath="$PROJECT_DIR$/Hajj-simulation.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
6
.idea/vcs.xml
Normal file
6
.idea/vcs.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
11
Hajj-simulation.iml
Normal file
11
Hajj-simulation.iml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="JAVA_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||||
|
<exclude-output />
|
||||||
|
<content url="file://$MODULE_DIR$">
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||||
|
</content>
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
</component>
|
||||||
|
</module>
|
51
src/Campaign.java
Normal file
51
src/Campaign.java
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
public class Campaign implements PermitedForHaj {
|
||||||
|
|
||||||
|
private int UID;
|
||||||
|
private int workers;
|
||||||
|
private int numberOfPeople;
|
||||||
|
private String district;
|
||||||
|
private String name;
|
||||||
|
private boolean local;
|
||||||
|
|
||||||
|
private Pilgrim[] pilgrims;
|
||||||
|
|
||||||
|
public Campaign(int numberOfPeople){
|
||||||
|
/*
|
||||||
|
Make an array of pilgrims based on number of people with
|
||||||
|
a set ration pilgrims:workers
|
||||||
|
Assume not local
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
public Campaign(Pilgrim[] pilgrims){
|
||||||
|
/*
|
||||||
|
Calculate number of workers based on number of pilgrims (pilgrims.length;)
|
||||||
|
Assume not local
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public int hasUID() {
|
||||||
|
return UID;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isLocal() {
|
||||||
|
return local;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getNumberofCars(){
|
||||||
|
//Assume each car holds 4 workers
|
||||||
|
return (int)workers/4;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getNumberOfBusses(){
|
||||||
|
int highPriorityPilgrims = 0;
|
||||||
|
int totalBusses = 0;
|
||||||
|
for (Pilgrim pilgrim : pilgrims){
|
||||||
|
if (pilgrim.getPriority() == Priority.HIGH) highPriorityPilgrims++;
|
||||||
|
}
|
||||||
|
totalBusses += highPriorityPilgrims/20; //Assume pilgims with physical disability
|
||||||
|
totalBusses += (pilgrims.length - highPriorityPilgrims)/40; //Remaining pilgrims fill busses
|
||||||
|
return totalBusses;
|
||||||
|
}
|
||||||
|
}
|
4
src/Gender.java
Normal file
4
src/Gender.java
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
public enum Gender {
|
||||||
|
MALE,
|
||||||
|
FEMALE
|
||||||
|
}
|
5
src/PermitedForHaj.java
Normal file
5
src/PermitedForHaj.java
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
public interface PermitedForHaj {
|
||||||
|
//public boolean has_UID();
|
||||||
|
public int hasUID();
|
||||||
|
public boolean isLocal();
|
||||||
|
}
|
31
src/Pilgrim.java
Normal file
31
src/Pilgrim.java
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
public class Pilgrim {
|
||||||
|
|
||||||
|
private String passport;
|
||||||
|
private boolean local;
|
||||||
|
private int age;
|
||||||
|
|
||||||
|
private Gender gender;
|
||||||
|
private Priority priority;
|
||||||
|
|
||||||
|
public Pilgrim(String passport, int age, Gender gender, Priority priority, boolean local) throws Exception {
|
||||||
|
setAge(age);
|
||||||
|
setPassport(passport);
|
||||||
|
this.gender = gender;
|
||||||
|
this.priority = priority;
|
||||||
|
}
|
||||||
|
public Priority getPriority() {
|
||||||
|
return priority;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setAge(int age) throws Exception {
|
||||||
|
if (age < 7 || age > 85) throw new Exception("Age out of permitted range");
|
||||||
|
else this.age = age;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setPassport(String passport) throws Exception {
|
||||||
|
if (passport.length() == 8) //assuming standard passport number lengths
|
||||||
|
this.passport = passport;
|
||||||
|
else throw new Exception("Invalid passport format");
|
||||||
|
//TODO:Make exception classes
|
||||||
|
}
|
||||||
|
}
|
5
src/Priority.java
Normal file
5
src/Priority.java
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
public enum Priority {
|
||||||
|
HIGH,
|
||||||
|
MID,
|
||||||
|
LOW
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user