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

[W7][T11-2]Li Guanlong #40

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
30 changes: 9 additions & 21 deletions README.adoc
Original file line number Diff line number Diff line change
@@ -1,41 +1,29 @@
= AddressBook (Level 3)
= Doctor On Call
ifdef::env-github,env-browser[:relfileprefix: docs/]
ifdef::env-github,env-browser[:imagesDir: docs/images]

https://travis-ci.org/se-edu/addressbook-level3[image:https://travis-ci.org/se-edu/addressbook-level3.svg?branch=master[Build Status]]
https://www.codacy.com/app/se-edu/addressbook-level3?utm_source=github.com&utm_medium=referral&utm_content=se-edu/addressbook-level3&utm_campaign=Badge_Grade[image:https://api.codacy.com/project/badge/Grade/d4a0954383444a8db8cb26e5f5b7302c[Codacy Badge]]
https://travis-ci.org/cs2113-ay1819s2-t11-2/main[image:https://travis-ci.org/cs2113-ay1819s2-t11-2/main.svg?branch=master[Build Status]]


image::Ui.png[]
* It is a Java sample application intended for hospital doctor who has several long-term patients he has to take care of.
* This appication was developed by team T11-2 of CS2113T in National University of Singapore


* This is a CLI (Command Line Interface) Address Book application *written in OOP fashion*. It has a very basic GUI.
* It is a Java sample application intended for students learning Software Engineering while using Java as
the main programming language.
* It provides a *reasonably well-written* code example that is *significantly bigger* than what students
usually write in data structure modules.

*What's different from level 2*

* A simple GUI added to replace the Text UI.
* A `Logic` class added together with a `LogicTest` class.
* Appendices added to <<DeveloperGuide#, Developer Guide>>

*Useful Links*

* <<UserGuide#, User Guide>>
* <<DeveloperGuide#, Developer Guide>>
* <<LearningOutcomes#, Learning Outcomes>>
* <<ContactUs#, Contact Us>>
* <<AboutUs#, About Us>>

== Contributors

The full list of contributors for se-edu can be found https://se-edu.github.io/Team.html[here].

== Acknowledgements
This application is morphed from AddressBook-Level3 project project created by SE-EDU initiative at https://github.com/se-edu/

Some parts of this sample application was inspired by the excellent
http://code.makery.ch/library/javafx-8-tutorial/[Java FX tutorial] by Marco Jakob

== Contact Us

* *Bug reports, Suggestions* : Post in our https://github.com/se-edu/addressbook-level3/issues[issue tracker]
if you noticed bugs or have suggestions on how to improve.
* *Contributing* : We welcome pull requests. Follow the process described https://github.com/oss-generic/process[here]
39 changes: 39 additions & 0 deletions docs/AboutUs.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
= About Us
:site-section: AboutUs

Doctor on Call was developed by the https://github.com/cs2113-ay1819s2-t11-2/main

== User Interface

image:https://raw.githubusercontent.com/cs2113-ay1819s2-t11-2/main/master/docs/images/Ui.png[width=820]

== The Project Team

'''

=== Wu Pei Hsuan
image:https://raw.githubusercontent.com/cs2113-ay1819s2-t11-2/main/master/docs/images/wupeihsuan.png[width=128]

Role: Developer

'''

=== Matthias Lum
image:https://raw.githubusercontent.com/cs2113-ay1819s2-t11-2/main/master/docs/images/matthiaslum.png[width=128]

Role: Developer

'''

=== Teo Xuan Wei
image:https://raw.githubusercontent.com/cs2113-ay1819s2-t11-2/main/master/docs/images/shawn-t.png[width=128]

Role: Developer

'''

=== Li Guanlong
image:https://github.com/cs2113-ay1819s2-t11-2/main/blob/master/docs/images/liguanlong.png?raw=true[width=128,height=128]

Role: Developer

5 changes: 5 additions & 0 deletions docs/ContactUs.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
== Contact Us

* *Bug reports, Suggestions* : Post in our https://github.com/cs2113-ay1819s2-t11-2/main/issues[issue tracker]
if you noticed bugs or have suggestions on how to improve.
* *Contributing* : We welcome pull requests. Follow the process described https://github.com/oss-generic/process[here]
45 changes: 39 additions & 6 deletions docs/DeveloperGuide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ Priorities: High (must have) - `* * \*`, Medium (nice to have) - `* \*`, Low (un
[width="100%",cols="22%,<23%,<25%,<30%",options="header",]
|===========================================================================================================================================
|Priority |As a ... |I want to ... |So that I can...
|`* * *` |new user |see usage instructions |refer to instructions when I forget how to use the App
|`* * *` |user |add a new person |
|`* * *` |user |delete a person |remove entries that I no longer need
|`* * *` |user |find a person by name |locate details of persons without having to go through the entire list
|`* *` |user |hide <<private-contact-detail, private contact details>> by default |minimize chance of someone else seeing them by accident
|`*` |user with many persons in the address book |sort persons by name |locate a person easily
|`* * *` |doctor |keep track of current and past appointments with patients that I have for the day |be on time to deliver treatment
|`* * *` |doctor |have a custom-made address book |filter out the patients that are not affiliated to me
|`* * *` |doctor |sort my patient according to my desired attribute |prioritize the allocation of my resources
|`* * *` |doctor |good authentication |my patients’ data are protected and not easily disclosed
|`* *` |doctor |have a doctor-referral system |refer patients to other doctors and the other doctors will be able to see the patients I passed to him
|`*` |doctor with many persons in the address book |sort persons by name |locate a person easily
|===========================================================================================================================================

[appendix]
Expand Down Expand Up @@ -81,6 +81,39 @@ Use case ends.
+
Use case resumes at step 2.

=== Use case: Login

*MSS*

. The user opens the addressbook
. Addressbook prompts’ user for username and password
. The user inputs the username/password and hits enter
. Addresbook authenticates the user and displays welcome address

Use case ends.

=== Use case: Referring a patient

*MSS*

. The user types refer NAME1 to NAME2 in the command line
. The information of the patient whose name is NAME1 is added to the addressbook of the doctor whose name is NAME2
. The information of the patient whose name is NAME1 is removed from the user’s addressbook

Use case ends.

=== Use case: Managing appointments

*MSS*

. The user types a command appointments in the command line
. The system finds all scheduled appointments and prints them to the screen in chronological order
. If possible, can print a literal timetable on the screen
. The expired appointments should be excluded from the timetable if possible


Use case ends.

[appendix]
== Non Functional Requirements

Expand Down
31 changes: 28 additions & 3 deletions docs/UserGuide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,25 @@ Format: `help`
Help is also shown if you enter an incorrect command e.g. `abcd`
====

== Login to the system : `login`

Allow the user to login to the system +
Format: `login username password`

[NOTE]
====
Login is required in order to use the address book
====

Examples:

* `login guanlong 12345` +
Logged in as guanlong if the account and password are correct.

== Adding a person: `add`

Adds a person to the address book. +
Format: `add NAME [p]p/PHONE_NUMBER [p]e/EMAIL [p]a/ADDRESS [t/TAG]...`
Format: `add NAME [p]p/PHONE_NUMBER [p]e/EMAIL [p]a/ADDRESS m/APPOINTMENTDATE [t/TAG]...`

****
Words in `UPPER_CASE` are the parameters, items in `SQUARE_BRACKETS` are optional,
Expand All @@ -46,14 +61,24 @@ Persons can have any number of tags (including 0)

Examples:

* `add John Doe p/98765432 e/[email protected] a/John street, block 123, #01-01`
* `add Betsy Crowe pp/1234567 e/[email protected] pa/Newgate Prison t/criminal t/friend`
* `add John Doe p/98765432 e/[email protected] a/John street, block 123, #01-01 m/30November`
* `add Betsy Crowe pp/1234567 e/[email protected] pa/Newgate Prison m/1 January 2009 t/criminal t/friend`

== Finding out the current length of the address book : `length`

Shows the number of entries in the address book. +
Format: `length`

== Listing all persons : `list`

Shows a list of all persons in the address book. +
Format: `list`

== Listing all persons in sorted order : `sort`

Shows a list of all persons sorted in alphabetical order in the address book. +
Format: `sort`

== Finding all persons containing any keyword in their name: `find`

Finds persons whose names contain any of the given keywords. +
Expand Down
Binary file added docs/images/Login_Register_Logout_activity.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/Login_Register_Logout_sequence.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/Ui.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/liguanlong.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/matthiaslum.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/shawn-t.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/wupeihsuan.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
69 changes: 69 additions & 0 deletions src/seedu/addressbook/accountmanager/AccountManager.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package seedu.addressbook.accountmanager;

import java.util.Map;
import java.util.HashMap;

public class AccountManager {

private boolean loginStatus;

public static final String LOGIN_PROMPT = "Please login or register in order to use the address book";
private static final String SUCCESS = "Login Success, loading...";
private static final String REGISTRATION_SUCCEED = "Registration succeed, please login using the username and password";
private static final String Invalid_USERNAME_OR_PASSWORD = "Invalid username or password, please try again";
private static final String Invalid_FORMAT = "Please login or register using: " + "\n" + "login username password" + "\n" + "register username password";
private static final String USERNAME_REGISTERED = "The username has already been registered, please try a new username";
private Map<String, String> accounts = new HashMap<String, String>();


public AccountManager(){
this.loginStatus = false;
this.accounts.put("guanlong", "12345");
this.accounts.put("doctorA", "doctorA");
}

public void setLoginStatus(boolean newStatus){
this.loginStatus = newStatus;
}

public boolean getLoginStatus(){
return loginStatus;
}

public String accountCommandHandler(String userCommandText){
String[] accountInfo = userCommandText.split(" ");
try {
if (accountInfo.length == 3 && accountInfo[0].equals("login")) {
if (accounts.containsKey(accountInfo[1]) && accounts.get(accountInfo[1]).equals(accountInfo[2])) {
this.loginStatus = true;
return SUCCESS;
}
else {
return Invalid_USERNAME_OR_PASSWORD;
}
}
else{
if (accountInfo.length == 3 && accountInfo[0].equals("register")){
String username = accountInfo[1];
if (accounts.containsKey(accountInfo[1]))
{
return(USERNAME_REGISTERED);
}
String password = accountInfo[2];
register(username, password);
return REGISTRATION_SUCCEED;
}
else{
return Invalid_FORMAT;
}
}
}
catch (Exception e){
return Invalid_FORMAT;
}
}

private void register(String username, String password){
accounts.put(username, password);
}
}
8 changes: 6 additions & 2 deletions src/seedu/addressbook/commands/AddCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ public class AddCommand extends Command {

public static final String MESSAGE_USAGE = COMMAND_WORD + ":\n" + "Adds a person to the address book. "
+ "Contact details can be marked private by prepending 'p' to the prefix.\n\t"
+ "Parameters: NAME [p]p/PHONE [p]e/EMAIL [p]a/ADDRESS [t/TAG]...\n\t"
+ "Parameters: NAME [p]p/PHONE [p]e/EMAIL [p]a/ADDRESS m/APPOINTMENT [t/TAG]...\n\t"
+ "Example: " + COMMAND_WORD
+ " John Doe p/98765432 e/[email protected] a/311, Clementi Ave 2, #02-25 t/friends t/owesMoney";
+ " John Doe p/98765432 e/[email protected] a/311, Clementi Ave 2, #02-25 m/30November t/friends t/owesMoney";

public static final String MESSAGE_SUCCESS = "New person added: %1$s";
public static final String MESSAGE_DUPLICATE_PERSON = "This person already exists in the address book";
Expand All @@ -34,6 +34,7 @@ public AddCommand(String name,
String phone, boolean isPhonePrivate,
String email, boolean isEmailPrivate,
String address, boolean isAddressPrivate,
String appointment,
Set<String> tags) throws IllegalValueException {
final Set<Tag> tagSet = new HashSet<>();
for (String tagName : tags) {
Expand All @@ -44,6 +45,7 @@ public AddCommand(String name,
new Phone(phone, isPhonePrivate),
new Email(email, isEmailPrivate),
new Address(address, isAddressPrivate),
new Appointment(appointment),
tagSet
);
}
Expand All @@ -60,6 +62,8 @@ public ReadOnlyPerson getPerson() {
public CommandResult execute() {
try {
addressBook.addPerson(toAdd);
System.out.println(toAdd);
System.out.println((String.format(MESSAGE_SUCCESS, toAdd)));
return new CommandResult(String.format(MESSAGE_SUCCESS, toAdd));
} catch (UniquePersonList.DuplicatePersonException dpe) {
return new CommandResult(MESSAGE_DUPLICATE_PERSON);
Expand Down
4 changes: 4 additions & 0 deletions src/seedu/addressbook/commands/Command.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ public static String getMessageForPersonListShownSummary(List<? extends ReadOnly
return String.format(Messages.MESSAGE_PERSONS_LISTED_OVERVIEW, personsDisplayed.size());
}

public static String getMessageForPersonSortShownSummary(List<? extends ReadOnlyPerson> personsDisplayed) {
return String.format(Messages.MESSAGE_PERSON_SORTED_OVERVIEW, personsDisplayed.size());
}

/**
* Executes the command and returns the result.
*/
Expand Down
2 changes: 2 additions & 0 deletions src/seedu/addressbook/commands/HelpCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ public class HelpCommand extends Command {
+ "\n" + DeleteCommand.MESSAGE_USAGE
+ "\n" + ClearCommand.MESSAGE_USAGE
+ "\n" + FindCommand.MESSAGE_USAGE
+ "\n" + LengthCommand.MESSAGE_USAGE
+ "\n" + ListCommand.MESSAGE_USAGE
+ "\n" + SortCommand.MESSAGE_USAGE
+ "\n" + ViewCommand.MESSAGE_USAGE
+ "\n" + ViewAllCommand.MESSAGE_USAGE
+ "\n" + HelpCommand.MESSAGE_USAGE
Expand Down
13 changes: 13 additions & 0 deletions src/seedu/addressbook/commands/LengthCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package seedu.addressbook.commands;

public class LengthCommand extends Command {
public static final String COMMAND_WORD = "length";
public static final String MESSAGE_USAGE = COMMAND_WORD + ":\n" + "Returns the current length of the address book at the point of query.\n\t"
+ "Example: " + COMMAND_WORD;
public static final String MESSAGE_SUCCESS = "Length of the address book is: ";

@Override
public CommandResult execute() {
return new CommandResult(MESSAGE_SUCCESS + addressBook.size());
}
}
31 changes: 31 additions & 0 deletions src/seedu/addressbook/commands/SortCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package seedu.addressbook.commands;

import seedu.addressbook.data.AddressBook;

import seedu.addressbook.data.person.ReadOnlyPerson;

import java.util.*;
import java.lang.*;


/**
* Lists all persons in the address book in sorted order to the user.
*/
public class SortCommand extends Command {

public static final String COMMAND_WORD = "sort";

public static final String MESSAGE_USAGE = COMMAND_WORD + ":\n"
+ "Displays all persons in the address book as a list sorted in alphabetical order with index numbers.\n\t"
+ "Example: " + COMMAND_WORD;


@Override
public CommandResult execute() {
addressBook.sorted();

List<ReadOnlyPerson> allPersons = addressBook.getAllPersons().immutableListView();
return new CommandResult(getMessageForPersonSortShownSummary(allPersons), allPersons);

}
}
1 change: 1 addition & 0 deletions src/seedu/addressbook/common/Messages.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public class Messages {
public static final String MESSAGE_INVALID_PERSON_DISPLAYED_INDEX = "The person index provided is invalid";
public static final String MESSAGE_PERSON_NOT_IN_ADDRESSBOOK = "Person could not be found in address book";
public static final String MESSAGE_PERSONS_LISTED_OVERVIEW = "%1$d persons listed!";
public static final String MESSAGE_PERSON_SORTED_OVERVIEW = "%1$d persons sorted in alphabetical order!";
public static final String MESSAGE_PROGRAM_LAUNCH_ARGS_USAGE = "Launch command format: " +
"java seedu.addressbook.Main [STORAGE_FILE_PATH]";
public static final String MESSAGE_WELCOME = "Welcome to your Address Book!";
Expand Down
Loading