Skip to content

Commit

Permalink
Pranesh V2
Browse files Browse the repository at this point in the history
bug fixes (local map) and improved packages
  • Loading branch information
Pranesh2002 authored Nov 22, 2022
1 parent 62c85c9 commit f529e2a
Show file tree
Hide file tree
Showing 22 changed files with 2,017 additions and 0 deletions.
Binary file added App.class
Binary file not shown.
74 changes: 74 additions & 0 deletions App.java
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 added Map/airdrop.class
Binary file not shown.
34 changes: 34 additions & 0 deletions Map/airdrop.java
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 added Map/basicmap.class
Binary file not shown.
18 changes: 18 additions & 0 deletions Map/basicmap.java
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 added Map/electricpower.class
Binary file not shown.
300 changes: 300 additions & 0 deletions Map/electricpower.java

Large diffs are not rendered by default.

Binary file added Map/enemybase.class
Binary file not shown.
Loading

0 comments on commit f529e2a

Please sign in to comment.