-
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.
Added map functionality and implemented airdrop. Abstract class Overridden method Packages and Exception handling (can improve).
- Loading branch information
1 parent
60d71ad
commit b491bd2
Showing
34 changed files
with
1,595 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,18 @@ | ||
## Getting Started | ||
|
||
Welcome to the VS Code Java world. Here is a guideline to help you get started to write Java code in Visual Studio Code. | ||
|
||
## Folder Structure | ||
|
||
The workspace contains two folders by default, where: | ||
|
||
- `src`: the folder to maintain sources | ||
- `lib`: the folder to maintain dependencies | ||
|
||
Meanwhile, the compiled output files will be generated in the `bin` folder by default. | ||
|
||
> If you want to customize the folder structure, open `.vscode/settings.json` and update the related settings there. | ||
## Dependency Management | ||
|
||
The `JAVA PROJECTS` view allows you to manage your dependencies. More details can be found [here](https://github.com/microsoft/vscode-java-dependency#manage-dependencies). |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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,90 @@ | ||
class airdrop { | ||
location airdroptt(location troop) | ||
{ | ||
basicmap 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); | ||
basicmap enemy=new enemyhotspot(); | ||
System.out.printf("Local map of enemy hotspot:\n"); | ||
enemy.localmap(l); | ||
return l; | ||
} | ||
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; | ||
} | ||
} | ||
public class App { | ||
public static void main(String[] args) throws Exception { | ||
|
||
|
||
location troop=new location(25,25); | ||
location l=new location(15,15); | ||
basicmap enemy=new enemyhotspot(); | ||
basicmap safelocation=new safelocation(); | ||
basicmap electricity=new electricpower(); | ||
basicmap fuel=new fuel(); | ||
basicmap water=new waterresources(); | ||
airdrop adp=new airdrop(); | ||
time t=new time(); | ||
|
||
// enemy.setlocation(troop,0); | ||
// enemy.printmap(); | ||
// enemy.localmap(troop); | ||
// l=enemy.nearestlocation(troop); | ||
// l.printlocation(); | ||
|
||
// adp.airdroptt(troop); | ||
|
||
// 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(); | ||
|
||
// fuel.setlocation(troop,3); | ||
// fuel.printmap(); | ||
// fuel.localmap(troop); | ||
// l=fuel.nearestlocation(troop); | ||
// l.printlocation(); | ||
|
||
// fuel.setlocation(troop,3); | ||
// fuel.printmap(); | ||
// fuel.localmap(troop); | ||
// l=fuel.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(); | ||
} | ||
} |
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,37 @@ | ||
public class airdrop { | ||
location airdroptt(location troop) | ||
{ | ||
safelocation s=new safelocation(); | ||
location l=new location(); | ||
l=s.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 e=new enemyhotspot(); | ||
System.out.printf("Local map of enemy hotspot:\n"); | ||
e.localmap(l); | ||
return l; | ||
} | ||
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=0; //s | ||
|
||
try{ | ||
totalseconds=distance/speed; //s | ||
}catch(ArithmeticException e){System.out.println(e);} | ||
|
||
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,17 @@ | ||
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; | ||
} | ||
} | ||
} | ||
abstract void setlocation(location l,int radius); | ||
abstract void printmap(); | ||
abstract void localmap(location l); | ||
abstract location nearestlocation(location l); | ||
} |
Binary file not shown.
Oops, something went wrong.