Skip to content

Commit

Permalink
Merge pull request #179 from ncaminh/master
Browse files Browse the repository at this point in the history
Fix issues, add Portfolio...
  • Loading branch information
ncaminh committed Apr 12, 2018
2 parents f1f5a50 + ff8bad2 commit 75df2d6
Show file tree
Hide file tree
Showing 39 changed files with 1,722 additions and 159 deletions.
Binary file added Collate-GUI.jar
Binary file not shown.
4 changes: 4 additions & 0 deletions collated/functional/mattbuot.md
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,10 @@ public class EmailCommand extends Command {
optimizedRoute = route.getAddresses(model);
String duration = FilterCommand.getStringDuration();

if (optimizedRoute.size() == 0) {
throw new CommandException("No address has be found, email not sent!");
}

boolean result =
Mailer.emailDriver(optimizedRoute, duration, delivDate)
&& Mailer.emailCustomers(model.getFilteredPersonList());
Expand Down
17 changes: 14 additions & 3 deletions collated/functional/meerakanani10.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ public class FilterCommand extends Command {
@Override
public CommandResult execute() throws CommandException, IOException {

```
###### \java\seedu\address\logic\commands\FilterCommand.java
``` java
RouteOptimization route = new RouteOptimization();
List<String> optimizedRoute;

Expand All @@ -33,8 +36,6 @@ public class FilterCommand extends Command {
```
###### \java\seedu\address\logic\commands\FilterCommand.java
``` java
}

@Override
public boolean equals(Object other) {
return other == this // short circuit if same object
Expand Down Expand Up @@ -122,6 +123,9 @@ public class FilterCommandParser implements Parser<FilterCommand> {
public class RouteOptimization {
public static final String HQ_ADDRESS = "Kent Ridge MRT";

```
###### \java\seedu\address\logic\RouteOptimization.java
``` java
/**
*
* @param model
Expand All @@ -142,7 +146,6 @@ public class RouteOptimization {
optimizedRoute.add(addressWithoutUnit);
}
} else {
//need to figure out what the key should be to make sure we know what the hashmap is storing
for (int i = 0; i < lastShownList.size(); i++) {
Address address = lastShownList.get(i).getAddress();
if (isFindableAddress(address)) {
Expand Down Expand Up @@ -208,6 +211,14 @@ public class RouteOptimization {
```
###### \java\seedu\address\logic\RouteOptimization.java
``` java

/**
* Recursive function to get the distance between addresses
* @param filteredAddresses - list of addresses
* @param origin - starting point
* @param optimizedRoute - optimized route that recursively get modified until completely optimized
* @return
*/
public List<String> getDistances(List<String> filteredAddresses, String origin, List<String> optimizedRoute) {
Map<String, Double> paths = new LinkedHashMap<>();
Map<String, Double> dummy = new HashMap<>();
Expand Down
77 changes: 77 additions & 0 deletions collated/functional/ncaminh-reusedgit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# ncaminh-reusedgit
###### \resources\games\Snake.html
``` html
<canvas id="gc" width="400" height="400"></canvas>
<script>
gc.style.left = "300px";
gc.style.top = "20px";
gc.style.position = "absolute";
window.onload=function() {
canv=document.getElementById("gc");
ctx=canv.getContext("2d");
document.addEventListener("keydown",keyPush);
setInterval(game,1000/15);
}
px=py=10;
gs=tc=20;
ax=ay=15;
xv=yv=0;
trail=[];
tail = 5;
function game() {
px+=xv;
py+=yv;
if(px<0) {
px= tc-1;
}
if(px>tc-1) {
px= 0;
}
if(py<0) {
py= tc-1;
}
if(py>tc-1) {
py= 0;
}
ctx.fillStyle="black";
ctx.fillRect(0,0,canv.width,canv.height);
ctx.fillStyle="lime";
for(var i=0;i<trail.length;i++) {
ctx.fillRect(trail[i].x*gs,trail[i].y*gs,gs-2,gs-2);
if(trail[i].x==px && trail[i].y==py) {
tail = 5;
}
}
trail.push({x:px,y:py});
while(trail.length>tail) {
trail.shift();
}
if(ax==px && ay==py) {
tail++;
ax=Math.floor(Math.random()*tc);
ay=Math.floor(Math.random()*tc);
}
ctx.fillStyle="red";
ctx.fillRect(ax*gs,ay*gs,gs-2,gs-2);
}
function keyPush(evt) {
switch(evt.keyCode) {
case 37:
xv=-1;yv=0;
break;
case 38:
xv=0;yv=-1;
break;
case 39:
xv=1;yv=0;
break;
case 40:
xv=0;yv=1;
break;
}
}
</script>
```
141 changes: 141 additions & 0 deletions collated/functional/ncaminh-unused-reused.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
# ncaminh-unused-reused
###### \resources\view\testMap.html
``` html
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<title>Displaying text directions with <code>setPanel()</code></title>
<style>
/* Always set the map height explicitly to define the size of the div
* element that contains the map. */
#map {
height: 100%;
}
/* Optional: Makes the sample page fill the window. */
html, body {
height: 100%;
margin: 0;
padding: 0;
}
#floating-panel {
position: absolute;
top: 10px;
left: 25%;
z-index: 5;
background-color: #fff;
padding: 5px;
border: 1px solid #999;
text-align: center;
font-family: 'Roboto','sans-serif';
line-height: 30px;
padding-left: 10px;
}
#right-panel {
font-family: 'Roboto','sans-serif';
line-height: 30px;
padding-left: 10px;
}
#right-panel select, #right-panel input {
font-size: 15px;
}
#right-panel select {
width: 100%;
}
#right-panel i {
font-size: 12px;
}
#right-panel {
height: 100%;
float: right;
width: 390px;
overflow: auto;
}
#map {
margin-right: 400px;
}
#floating-panel {
background: #fff;
padding: 5px;
font-size: 14px;
font-family: Arial;
border: 1px solid #ccc;
box-shadow: 0 2px 2px rgba(33, 33, 33, 0.4);
display: none;
}
@media print {
#map {
height: 500px;
margin: 0;
}
#right-panel {
float: none;
width: auto;
}
}
</style>
</head>
<body>
<div id="floating-panel">
<strong>Start:</strong>
<select id="start">
<option value="Singapore+118177">Kent Ridge MRT</option>
<option value="Singapore+139349">Buona Vista MRT</option>
</select>
<br>
<strong>End:</strong>
<select id="end">
<option value="Singapore+118177">Kent Ridge MRT</option>
<option value="Singapore+139349">Buona Vista MRT</option>
</select>
</div>
<div id="right-panel"></div>
<div id="map"></div>
<script>
function initMap() {
var directionsDisplay = new google.maps.DirectionsRenderer;
var directionsService = new google.maps.DirectionsService;
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 15,
center: {lat: 1.2925, lng: 103.7849}
});
directionsDisplay.setMap(map);
directionsDisplay.setPanel(document.getElementById('right-panel'));
var control = document.getElementById('floating-panel');
control.style.display = 'block';
map.controls[google.maps.ControlPosition.TOP_CENTER].push(control);
var onChangeHandler = function() {
calculateAndDisplayRoute(directionsService, directionsDisplay);
};
document.getElementById('start').addEventListener('change', onChangeHandler);
document.getElementById('end').addEventListener('change', onChangeHandler);
}
function calculateAndDisplayRoute(directionsService, directionsDisplay) {
var start = document.getElementById('start').value;
var end = document.getElementById('end').value;
directionsService.route({
origin: start,
destination: end,
travelMode: 'DRIVING'
}, function(response, status) {
if (status === 'OK') {
directionsDisplay.setDirections(response);
} else {
window.alert('Directions request failed due to ' + status);
}
});
}
</script>
<script async defer
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBWyCJkCym1dSouzHX_FxLk6Tj11C7F0Ao&callback=initMap">
</script>
</body>
</html>
```
77 changes: 77 additions & 0 deletions collated/functional/ncaminh-unused.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# ncaminh-unused
###### \resources\games\Snake.html
``` html
<canvas id="gc" width="400" height="400"></canvas>
<script>
gc.style.left = "300px";
gc.style.top = "20px";
gc.style.position = "absolute";
window.onload=function() {
canv=document.getElementById("gc");
ctx=canv.getContext("2d");
document.addEventListener("keydown",keyPush);
setInterval(game,1000/15);
}
px=py=10;
gs=tc=20;
ax=ay=15;
xv=yv=0;
trail=[];
tail = 5;
function game() {
px+=xv;
py+=yv;
if(px<0) {
px= tc-1;
}
if(px>tc-1) {
px= 0;
}
if(py<0) {
py= tc-1;
}
if(py>tc-1) {
py= 0;
}
ctx.fillStyle="black";
ctx.fillRect(0,0,canv.width,canv.height);
ctx.fillStyle="lime";
for(var i=0;i<trail.length;i++) {
ctx.fillRect(trail[i].x*gs,trail[i].y*gs,gs-2,gs-2);
if(trail[i].x==px && trail[i].y==py) {
tail = 5;
}
}
trail.push({x:px,y:py});
while(trail.length>tail) {
trail.shift();
}
if(ax==px && ay==py) {
tail++;
ax=Math.floor(Math.random()*tc);
ay=Math.floor(Math.random()*tc);
}
ctx.fillStyle="red";
ctx.fillRect(ax*gs,ay*gs,gs-2,gs-2);
}
function keyPush(evt) {
switch(evt.keyCode) {
case 37:
xv=-1;yv=0;
break;
case 38:
xv=0;yv=-1;
break;
case 39:
xv=1;yv=0;
break;
case 40:
xv=0;yv=1;
break;
}
}
</script>
```

0 comments on commit 75df2d6

Please sign in to comment.