Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New branch #18

Merged
merged 43 commits into from
Nov 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
d429229
Merge pull request #119 from cjunxiang/pr/15
arjo129 Nov 7, 2018
570862a
fixing some minor stuff
arjo129 Nov 7, 2018
db41f5e
Merge remote-tracking branch 'upstream/master'
arjo129 Nov 7, 2018
dd7b2a9
Merge pull request #16 from cjunxiang/pr/15
cjunxiang Nov 8, 2018
ff39b9e
TimeZone Limits settled
cjunxiang Nov 8, 2018
fb0490c
timezone
cjunxiang Nov 8, 2018
7481a65
checkstyles
cjunxiang Nov 8, 2018
1e70bcf
checkstyles
cjunxiang Nov 8, 2018
5bf2503
PortOver Feature and refined Exit Planning Mode
cjunxiang Nov 8, 2018
cfd3125
trivial issue
cjunxiang Nov 8, 2018
9ce5400
checkstyles
cjunxiang Nov 8, 2018
d598c7e
checkstyles
cjunxiang Nov 8, 2018
e8c41d2
checkstyle lol
cjunxiang Nov 9, 2018
5ff8fef
forgot to add in a method
cjunxiang Nov 9, 2018
eb842ac
Added gradient to the color
TTTaus Nov 9, 2018
2d8d2b7
Merge pull request #128 from cjunxiang/PortOver
shuanang Nov 9, 2018
2cae82a
Merge remote-tracking branch 'CS2113-AY1819S1-W13-2/master'
TTTaus Nov 9, 2018
6334eb3
Squashed the microbe
TTTaus Nov 9, 2018
d4f7d6f
Squashed the travis error
TTTaus Nov 9, 2018
64ccab9
Squash Mr Travis
TTTaus Nov 9, 2018
a42aded
Killed Mr Travis
TTTaus Nov 9, 2018
36d87ff
Merge pull request #129 from TTTaus/CSSGradient
shuanang Nov 9, 2018
f5c36a7
dealing with maxBottomTimes
shuanang Nov 9, 2018
b624d7a
checkstyle
shuanang Nov 9, 2018
7020fc3
checkstyles
shuanang Nov 9, 2018
0a25337
Merge pull request #131 from shuanang/master
shuanang Nov 9, 2018
692c34d
prevents overlapping dives
arjo129 Nov 10, 2018
6773aaf
resolved the merge conflicts
arjo129 Nov 10, 2018
19ab83b
fixed unit tests who failed due to overlapping dives
arjo129 Nov 10, 2018
62bc910
fixed unit tests who failed due to bad typical dive list
arjo129 Nov 10, 2018
52c5ac2
Time params
cjunxiang Nov 10, 2018
84fa8c1
fixed unit test for overlapping dives
arjo129 Nov 10, 2018
fb082f0
checkstyles
cjunxiang Nov 10, 2018
3230dba
checkstyle issues
arjo129 Nov 10, 2018
32a21c2
fixed comment order
arjo129 Nov 10, 2018
416ac2d
removed unused imports from tests
arjo129 Nov 10, 2018
b97e22f
Merge pull request #132 from cjunxiang/PortOver
arjo129 Nov 10, 2018
8bb7d15
Fixed merge conflict
arjo129 Nov 10, 2018
6978539
units now modified as inputs
arjo129 Nov 10, 2018
8406f71
fixed a bug with the set_units input
arjo129 Nov 10, 2018
f12dc0b
hopefully removed the whole header
arjo129 Nov 10, 2018
e19f9c5
Merge pull request #133 from arjo129/master
shuanang Nov 10, 2018
3a9cdac
Merge branch 'practicalExam2' into master
cjunxiang Nov 10, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,9 @@ asciidoctor {
idprefix: '', // for compatibility with GitHub preview
idseparator: '-',
'site-root': "${sourceDir}", // must be the same as sourceDir, do not modify
'site-name': 'AddressBook-Level4',
'site-githuburl': 'https://github.com/se-edu/addressbook-level4',
'site-seedu': true, // delete this line if your project is not a fork (not a SE-EDU project)
'site-name': 'DiveLog',
'site-githuburl': 'https://github.com/CS2113-AY1819S1-W13-2/main',
'site-seedu': false, // delete this line if your project is not a fork (not a SE-EDU project)
]

options['template_dirs'].each {
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/seedu/divelog/commons/core/Messages.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public class Messages {
+ "Start Date should be earlier than End Date!\n"
+ "Safety Stop should be between Start and End time";
public static final String MESSAGE_INVALID_TIMEZONE_FORMAT = "Invalid timezone format! (UTC format)";
public static final String MESSAGE_INTERNAL_ERROR = "An internal error occured";
public static final String MESSAGE_ERROR_LIMIT_EXCEED = "Dive is too deep and too long!!";
public static final String MESSAGE_ERROR_DIVES_OVERLAP =
"The dive overlaps with another dive. Not updating the divelog.";
}
2 changes: 1 addition & 1 deletion src/main/java/seedu/divelog/commons/util/CompareUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class CompareUtil {
* Tells time difference between 2 timings in MINUTES (long)
*/
public static long checkTimeDifference(String startTime, String endTime, String startDate, String endDate)
throws Exception {
throws ParseException {
SimpleDateFormat format = new SimpleDateFormat("ddMMyyyyHHmm");
String startTimeDate = startDate.concat(startTime);
String endTimeDate = endDate.concat(endTime);
Expand Down
19 changes: 12 additions & 7 deletions src/main/java/seedu/divelog/logic/commands/AddCommand.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
package seedu.divelog.logic.commands;

import static java.util.Objects.requireNonNull;
import static seedu.divelog.commons.core.Messages.MESSAGE_ERROR_DIVES_OVERLAP;
import static seedu.divelog.commons.core.Messages.MESSAGE_ERROR_LIMIT_EXCEED;
import static seedu.divelog.commons.core.Messages.MESSAGE_INVALID_TIME_FORMAT;

import seedu.divelog.logic.CommandHistory;
import seedu.divelog.logic.commands.exceptions.CommandException;
import seedu.divelog.logic.parser.CliSyntax;
import seedu.divelog.logic.pressuregroup.exceptions.LimitExceededException;
import seedu.divelog.model.Model;
import seedu.divelog.model.dive.DiveSession;
import seedu.divelog.model.dive.exceptions.DiveOverlapsException;
import seedu.divelog.model.dive.exceptions.InvalidTimeException;

/**
* Adds a dive to the divelog book.
Expand All @@ -24,7 +29,6 @@ public class AddCommand extends Command {
+ CliSyntax.PREFIX_TIME_END + "END_TIME (24Hr Format) "
+ CliSyntax.PREFIX_SAFETY_STOP + "SAFETY_STOP_TIME (24Hr Format) \n\t"
+ CliSyntax.PREFIX_DEPTH + "DEPTH "
+ CliSyntax.PREFIX_PRESSURE_GROUP_START + "PRESSURE_GROUP_START "
+ CliSyntax.PREFIX_LOCATION + "LOCATION"
+ CliSyntax.PREFIX_TIMEZONE + "TIMEZONE\n"
+ "Example: " + COMMAND_WORD + " "
Expand All @@ -34,7 +38,6 @@ public class AddCommand extends Command {
+ CliSyntax.PREFIX_TIME_END + "0800 "
+ CliSyntax.PREFIX_SAFETY_STOP + "0745 "
+ CliSyntax.PREFIX_DEPTH + "16 "
+ CliSyntax.PREFIX_PRESSURE_GROUP_START + "A "
+ CliSyntax.PREFIX_LOCATION + "Sentosa "
+ CliSyntax.PREFIX_TIMEZONE + "+8";

Expand All @@ -56,19 +59,21 @@ public AddCommand(DiveSession dive) {
* then adds accordingly
*/
@Override
public CommandResult execute(Model model, CommandHistory history) {
model.addDiveSession(toAdd);
public CommandResult execute(Model model, CommandHistory history) throws CommandException {

try {
model.recalculatePressureGroups();
model.addDiveSession(toAdd);
model.commitDiveLog();
if (model.getPlanningMode()) {
model.plannerCountPlus();
}
} catch (LimitExceededException le) {
return new CommandResult(MESSAGE_ERROR_LIMIT_EXCEED);
throw new CommandException(MESSAGE_ERROR_LIMIT_EXCEED);
} catch (InvalidTimeException ive) {
throw new CommandException(MESSAGE_INVALID_TIME_FORMAT);
} catch (DiveOverlapsException de) {
throw new CommandException(MESSAGE_ERROR_DIVES_OVERLAP);
}

return new CommandResult(MESSAGE_SUCCESS);
}

Expand Down
5 changes: 1 addition & 4 deletions src/main/java/seedu/divelog/logic/commands/Command.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
package seedu.divelog.logic.commands;

import java.text.ParseException;

import seedu.divelog.logic.CommandHistory;
import seedu.divelog.logic.commands.exceptions.CommandException;
import seedu.divelog.model.Model;
import seedu.divelog.model.dive.exceptions.InvalidTimeException;

/**
* Represents a command with hidden internal logic and the ability to be executed.
Expand All @@ -21,6 +18,6 @@ public abstract class Command {
* @throws CommandException If an error occurs during command execution.
*/
public abstract CommandResult execute(Model model, CommandHistory history)
throws CommandException, ParseException, InvalidTimeException;
throws CommandException;

}
19 changes: 11 additions & 8 deletions src/main/java/seedu/divelog/logic/commands/CurrentPgCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,19 +69,19 @@ public CommandResult execute(Model model, CommandHistory history) throws Command
int singleDivePreFlightSurfaceIntervalMinutes = 12 * 60;
int repeatDivePreFlightSurfaceIntervalMinutes = 18 * 60;
if ((currentPg.getPressureGroup().equals("A")) && (firstDive == 0)
&& (surfaceDuration >= singleDivePreFlightSurfaceIntervalMinutes)) {
&& (surfaceDuration >= singleDivePreFlightSurfaceIntervalMinutes)) {
//check if there is any dive in the past 12 hours for single dives
return new CommandResult("Based on your latest dive(s), "
+ "your current pressure group is already A." + "\n"
+ "It has been at least 12 hours since your last SINGLE dive - you can safely fly!");
+ "your current pressure group is already A." + "\n"
+ "It has been at least 12 hours since your last SINGLE dive - you can safely fly!");
}
if ((currentPg.getPressureGroup().equals("A")) && (firstDive == 1)
&& (surfaceDuration >= repeatDivePreFlightSurfaceIntervalMinutes)) {
//check if there is any dive in the past 18 hours for repeat/multi-day dives
return new CommandResult("Based on your latest dive(s),"
+ " your current pressure group is already A." + "\n"
+ " your current pressure group is already A." + "\n"
+ " It has been at least 18 hours since your last dive of your repetitive dive series"
+ " - you can safely fly!");
+ " - you can safely fly!");
}
long singleDiveToFlightTime = singleDivePreFlightSurfaceIntervalMinutes - surfaceDuration;
long repeatDiveToFlightTime = repeatDivePreFlightSurfaceIntervalMinutes - surfaceDuration;
Expand All @@ -90,9 +90,11 @@ public CommandResult execute(Model model, CommandHistory history) throws Command
return new CommandResult(MESSAGE_CURRENTPG + currentPg.getPressureGroup() + "\n"
+ MESSAGE_TIMETONEXT + nextPg + ": " + timeToNextPg + " minutes." + "\n"
+ MESSAGE_TIMETOMIN + timeToMinPg + " minutes, at: " + dateFormat.format(minPgCal.getTime())
+ "\n" + "You just completed a single dive, ended on " + lastDive.getDateEnd().getOurDateString() + " "
+ "\n" + "You just completed a single dive, ended on "
+ lastDive.getDateEnd().getOurDateString() + " "
+ lastDive.getEnd().getTimeString()
+ "hrs. You are recommended to wait at least 12 hours on land "
+ "hrs." + "\n"
+ "You are recommended to wait at least 12 hours on land "
+ "before flying." + "\n"
+ "You can safely fly from: " + dateFormat.format(timeToFlightCal.getTime()) + " onwards.");
}
Expand All @@ -104,7 +106,8 @@ public CommandResult execute(Model model, CommandHistory history) throws Command
+ "\n" + "You just completed a repetitive/multi-day dive, ended on "
+ lastDive.getDateEnd().getOurDateString() + " "
+ lastDive.getEnd().getTimeString()
+ "hrs. You are recommended to wait at least 18 hours on land before flying." + "\n"
+ "hrs." + "\n"
+ "You are recommended to wait at least 18 hours on land before flying." + "\n"
+ "You can safely fly from: " + dateFormat.format(timeToFlightCal.getTime()) + " onwards.");
}
} catch (Exception e) {
Expand Down
55 changes: 35 additions & 20 deletions src/main/java/seedu/divelog/logic/commands/EditCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,17 @@

import static java.util.Objects.requireNonNull;

import java.text.ParseException;
import java.util.List;
import java.util.Optional;
import java.util.logging.Logger;

import seedu.divelog.commons.core.LogsCenter;
import seedu.divelog.commons.core.Messages;
import seedu.divelog.commons.core.index.Index;
import seedu.divelog.commons.util.CollectionUtil;
import seedu.divelog.logic.CommandHistory;
import seedu.divelog.logic.commands.exceptions.CommandException;
import seedu.divelog.logic.parser.CliSyntax;
import seedu.divelog.logic.parser.ParserUtil;
import seedu.divelog.logic.parser.exceptions.ParseException;
import seedu.divelog.logic.pressuregroup.exceptions.LimitExceededException;
import seedu.divelog.model.Model;
import seedu.divelog.model.dive.DepthProfile;
Expand All @@ -24,6 +22,8 @@
import seedu.divelog.model.dive.PressureGroup;
import seedu.divelog.model.dive.Time;
import seedu.divelog.model.dive.TimeZone;
import seedu.divelog.model.dive.exceptions.DiveNotFoundException;
import seedu.divelog.model.dive.exceptions.DiveOverlapsException;
import seedu.divelog.model.dive.exceptions.InvalidTimeException;


Expand All @@ -44,7 +44,7 @@ public class EditCommand extends Command {
+ "[" + CliSyntax.PREFIX_TIME_END + "TIME_END] "
+ "[" + CliSyntax.PREFIX_SAFETY_STOP + "SAFETY_STOP_TIME] "
+ "[" + CliSyntax.PREFIX_DEPTH + "DEPTH] "
+ "[" + CliSyntax.PREFIX_PRESSURE_GROUP_START + "PG_AT_START] "
//+ "[" + CliSyntax.PREFIX_PRESSURE_GROUP_START + "PG_AT_START] "
//+ "[" + CliSyntax.PREFIX_PRESSURE_GROUP_END + "PG_AT_END] "
+ "[" + CliSyntax.PREFIX_LOCATION + "LOCATION]\n"
+ "Example: " + COMMAND_WORD + " 1 "
Expand All @@ -70,8 +70,7 @@ public EditCommand(Index index, EditDiveDescriptor editDiveDescriptor) {
}

@Override
public CommandResult execute(Model model, CommandHistory history)
throws CommandException, ParseException, InvalidTimeException {
public CommandResult execute(Model model, CommandHistory history) throws CommandException {
requireNonNull(model);
List<DiveSession> lastShownList = model.getFilteredDiveList();

Expand All @@ -80,26 +79,29 @@ public CommandResult execute(Model model, CommandHistory history)
}

DiveSession diveToEdit = lastShownList.get(index.getZeroBased());
DiveSession editedDive = null;

editedDive = createEditedDive(diveToEdit, editDiveDescriptor);
DiveSession editedDive = createEditedDive(diveToEdit, editDiveDescriptor);


try {
model.updateDiveSession(diveToEdit, editedDive);
} catch (seedu.divelog.model.dive.exceptions.DiveNotFoundException e) {
return new CommandResult(Messages.MESSAGE_INVALID_DIVE_DISPLAYED_INDEX);
ParserUtil.checkEditTimeDateLimit(editedDive);
} catch (ParseException e) {
throw new CommandException(e.getMessage());
}

try {
Logger logs = LogsCenter.getLogger(EditCommand.class);
logs.info("Recalculating pressure groups");
model.recalculatePressureGroups();
model.commitDiveLog();
} catch (LimitExceededException e) {
model.undoDiveLog();
return new CommandResult(Messages.MESSAGE_ERROR_LIMIT_EXCEED);
model.updateDiveSession(diveToEdit, editedDive);
} catch (DiveNotFoundException e) {
throw new CommandException(Messages.MESSAGE_INVALID_DIVE_DISPLAYED_INDEX);
} catch (InvalidTimeException ive) {
throw new CommandException(Messages.MESSAGE_INVALID_TIME_FORMAT);
} catch (LimitExceededException le) {
throw new CommandException(Messages.MESSAGE_ERROR_LIMIT_EXCEED);
} catch (DiveOverlapsException overlap) {
throw new CommandException(Messages.MESSAGE_ERROR_DIVES_OVERLAP);
}

model.commitDiveLog();
model.updateFilteredDiveList(Model.PREDICATE_SHOW_ALL_DIVES);

if (model.getPlanningMode()) {
Expand All @@ -113,8 +115,14 @@ public CommandResult execute(Model model, CommandHistory history)
* edited with {@code editDiveDescriptor}.
*/
private static DiveSession createEditedDive(DiveSession diveToEdit, EditDiveDescriptor editDiveSessionDescriptor)
throws InvalidTimeException, ParseException {
throws CommandException {

assert diveToEdit != null;

if (!editDiveSessionDescriptor.isAnyFieldEdited()) {
throw new CommandException(MESSAGE_NOT_EDITED);
}

OurDate dateStart = editDiveSessionDescriptor.getDateStart().orElse(diveToEdit.getDateStart());
Time start = editDiveSessionDescriptor.getStart().orElse(diveToEdit.getStart());
OurDate dateEnd = editDiveSessionDescriptor.getDateEnd().orElse(diveToEdit.getDateEnd());
Expand All @@ -131,7 +139,14 @@ private static DiveSession createEditedDive(DiveSession diveToEdit, EditDiveDesc
DiveSession editedDive = new DiveSession(dateStart, start, safetyStop, dateEnd, end,
pressureGroupAtBeginning, pressureGroupAtEnd, location, depth, timezone);

ParserUtil.checkEditTimeDateLimit(editedDive);
try {
ParserUtil.checkTimeZoneformat(timezone.getTimeZoneString());
ParserUtil.checkEditTimeDateLimit(editedDive);
} catch (ParseException e) {
throw new CommandException(e.getMessage());
}


return editedDive;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package seedu.divelog.logic.commands;

import seedu.divelog.logic.CommandHistory;
import seedu.divelog.logic.commands.exceptions.CommandException;
import seedu.divelog.model.Model;

/**
* exits planning mode
*/
public class ExitPlanningCommand extends Command {
public static final String COMMAND_WORD_NORMAL = "normalmode";

public static final String MESSAGE_EXIT = "You're now in Normal Mode";

@Override
public CommandResult execute(Model model, CommandHistory history) throws CommandException {
if (model.getPlanningMode()) {
while (model.getPlannerCount() > 0) {
model.undoDiveLog();
model.plannerCountMinus();
}
model.setPlanningMode();
return new CommandResult(MESSAGE_EXIT);
} else {
throw new CommandException("You are already in Normal Mode.");
}
}
}
15 changes: 5 additions & 10 deletions src/main/java/seedu/divelog/logic/commands/PlanningCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,18 @@
public class PlanningCommand extends Command {

public static final String COMMAND_WORD_PLAN = "newplan";
public static final String COMMAND_WORD_NORMAL = "normalmode";

public static final String MESSAGE_ENTRY = "You're now in Planning Mode";
public static final String MESSAGE_EXIT = "You're now in Normal Mode";


@Override
public CommandResult execute(Model model, CommandHistory history) throws CommandException {
if (model.getPlanningMode()) {
while (model.getPlannerCount() > 0) {
model.undoDiveLog();
model.plannerCountMinus();
}
if (!model.getPlanningMode()) {
model.zeroPlannerCount();
model.setPlanningMode();
return new CommandResult(MESSAGE_EXIT);
return new CommandResult(MESSAGE_ENTRY);
} else {
throw new CommandException("You are already in Planning Mode, and thus cannot enter Planning Mode");
}
model.setPlanningMode();
return new CommandResult(MESSAGE_ENTRY);
}
}
33 changes: 33 additions & 0 deletions src/main/java/seedu/divelog/logic/commands/PortOverCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package seedu.divelog.logic.commands;

import seedu.divelog.logic.CommandHistory;
import seedu.divelog.logic.commands.exceptions.CommandException;
import seedu.divelog.model.Model;

//author @Cjunx
/**
* Ports Over Planning mode
*/
public class PortOverCommand extends Command {
public static final String COMMAND_WORD_PORT_OVER = "portover";

public static final String MESSAGE_ENTRY = "You've successfully ported over your planning dives";

@Override
public CommandResult execute(Model model, CommandHistory history) throws CommandException {
if (model.getPlanningMode()) {
if (model.getPlannerCount() == 0) {
String messageNoData = "You have yet to input any planning dives to port over";
throw new CommandException(messageNoData);
}
model.zeroPlannerCount();
model.setPlanningMode();
return new CommandResult(MESSAGE_ENTRY);
} else {
String messageFailure = "You are not in planning mode thus you have no data to port over";
throw new CommandException(messageFailure);
}
}
}