-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bug fixes (local map) and improved packages
- Loading branch information
1 parent
62c85c9
commit f529e2a
Showing
22 changed files
with
2,017 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
// package Map; | ||
import Map.*; | ||
|
||
public class App { | ||
public static void main(String[] args) throws Exception { | ||
|
||
|
||
location troop=new location(63,69); | ||
location l=new location(3,96); | ||
basicmap enemy=new enemyhotspot(); | ||
basicmap safelocation=new safelocation(); | ||
basicmap electricity=new electricpower(); | ||
basicmap f=new fuel(); | ||
basicmap water=new waterresources(); | ||
airdrop adp=new airdrop(); | ||
time t=new time(); | ||
|
||
enemy.setlocation(l,2); | ||
enemy.printmap(); | ||
enemy.localmap(l); | ||
l=enemy.nearestlocation(troop); | ||
l.printlocation(); | ||
|
||
safelocation.setlocation(troop,1); | ||
safelocation.printmap(); | ||
safelocation.localmap(troop); | ||
l=safelocation.nearestlocation(troop); | ||
l.printlocation(); | ||
|
||
electricity.setlocation(troop,3); | ||
electricity.printmap(); | ||
electricity.localmap(troop); | ||
l=electricity.nearestlocation(troop); | ||
l.printlocation(); | ||
|
||
f.setlocation(troop,3); | ||
f.printmap(); | ||
f.localmap(troop); | ||
l=f.nearestlocation(troop); | ||
l.printlocation(); | ||
|
||
// f.setlocation(troop,3); | ||
// f.printmap(); | ||
// f.localmap(troop); | ||
// l=f.nearestlocation(troop); | ||
// l.printlocation(); | ||
|
||
water.setlocation(troop,3); | ||
water.printmap(); | ||
water.localmap(troop); | ||
l=water.nearestlocation(troop); | ||
l.printlocation(); | ||
|
||
basicmap enemybase=new enemybase(); | ||
enemybase.printmap(); | ||
l=enemybase.nearestlocation(troop); | ||
l.printlocation(); | ||
|
||
adp.airdroptt(troop); | ||
|
||
/* | ||
location object saves the location (latitude,longitude) (0<=latitude<50,0<=longitude<100) | ||
latitude is | | ||
longitude is --- | ||
for all the map objects | ||
.printmap() prints the map | ||
.localmap(location l) prints the objects local map of the given location | ||
.nearestlocation(location troop) returns nearest object of the respective class | ||
airdrop | ||
.setlocation(location l) sets the give objects map value at location to 1 | ||
airdropclassobject.airdroptt(location troop) prints the location and time of delivery | ||
*/ | ||
} | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package Map; | ||
|
||
public class airdrop { | ||
public location airdroptt(location troop) | ||
{ | ||
safelocation safe=new safelocation(); | ||
location l=new location(); | ||
l=safe.nearestlocation(troop); | ||
System.out.printf("The package will arrive at (%d,%d).\n", l.la,l.lo); | ||
time t= new time(); | ||
t= gettime(l); | ||
enemyhotspot enemy=new enemyhotspot(); | ||
System.out.printf("Local map of enemy hotspot:\n"); | ||
enemy.localmap(l); | ||
return l; | ||
} | ||
public time gettime(location l) | ||
{ | ||
// set time now | ||
time t= new time(); | ||
double distance=0; // in m | ||
distance = Math.sqrt(((l.la-50)*(l.la-50)+(l.lo-50)*(l.lo-50))*10000); // scale *1000 m 1 km | ||
double speed=100; //in mps | ||
double totalseconds=distance/speed; //s | ||
int hours = (int)totalseconds / 3600; | ||
int minutes = (int)(totalseconds % 3600) / 60; | ||
int seconds = (int)totalseconds % 60; | ||
System.out.printf("The package will reach the destination at : %02d:%02d:%02d (hh:mm:ss)\n", hours, minutes, seconds); | ||
t.hours=hours; | ||
t.minutes=minutes; | ||
t.seconds=seconds; | ||
return t; | ||
} | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package Map; | ||
public abstract class basicmap{ // all maps are of size 100*50 from (0 to 99) and (0 to 49) | ||
int[][] basicmap=new int[100][50]; | ||
basicmap() | ||
{ | ||
for(int i=0;i<50;i++) | ||
{ | ||
for(int j=0;j<100;j++) | ||
{ | ||
basicmap[j][i]=0; | ||
} | ||
} | ||
} | ||
public abstract void setlocation(location l,int radius); | ||
public abstract void printmap(); | ||
public abstract void localmap(location l); | ||
public abstract location nearestlocation(location l); | ||
} |
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
Oops, something went wrong.