Skip to content

Commit

Permalink
Revert "Save and Retrieve"
Browse files Browse the repository at this point in the history
  • Loading branch information
yentheng0110 authored Oct 1, 2024
1 parent dac92b3 commit 16e1943
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 246 deletions.
91 changes: 0 additions & 91 deletions src/main/java/BookBob/entity/Patient.java

This file was deleted.

30 changes: 0 additions & 30 deletions src/main/java/BookBob/entity/Records.java

This file was deleted.

29 changes: 0 additions & 29 deletions src/main/java/BookBob/functions/CRUD.java

This file was deleted.

83 changes: 0 additions & 83 deletions src/main/java/BookBob/functions/SaveAndRetrieve.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package BookBob;
package seedu.duke;

import java.util.Scanner;

public class Main {
public class Duke {
/**
* Main entry-point for the java.duke.Duke application.
*/
Expand Down
21 changes: 21 additions & 0 deletions src/main/java/seedu/duke/Patient.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package seedu.duke;

import java.util.ArrayList;

public class Patient {
public String name;
public String nric;
public String address;
public ArrayList<String> medication;
public String diagnosis;
public String dateOfBirth;

Patient(String name, String nric) {
this.name = name;
this.nric = nric;
this.address = "";
this.medication = new ArrayList<>();
this.diagnosis = "";
this.dateOfBirth = "";
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
package BookBob.functions;
package seedu.duke;

public class CommandHandler {
import java.util.ArrayList;

public class Records {
public ArrayList<Patient> patients;

Records() {
patients = new ArrayList<>();
}

// Takes in an input string and determines whether to exit the program
public void exit(String input) {
if(input.equalsIgnoreCase("exit")) {
System.exit(0);
}
}

// Prints output for help command
public void help() {
Expand All @@ -25,20 +39,31 @@ public void help() {
"+-----------+---------------------------------------+---------------------------------+\n" +
"| Delete | delete NRIC | delete S9534567A |\n" +
"+-----------+---------------------------------------+---------------------------------+\n" +
"| Save | save(automatic) | save |\n" +
"| Save | save | save |\n" +
"+-----------+---------------------------------------+---------------------------------+\n" +
"| Retrieve/ | retrieve or import | retrieve |\n" +
"| Import | (automatic) | |\n" +
"| Import | | |\n" +
"+-----------+---------------------------------------+---------------------------------+\n" +
"| Exit | exit | exit |\n" +
"+-----------+---------------------------------------+---------------------------------+\n");
}

// Takes in an input string and determines whether to exit the program
public void exit(String input) {
if(input.equalsIgnoreCase("exit")) {
System.exit(0);
public void delete(String nric) {
int initialPatientSize = patients.size();
if (patients.isEmpty()) {
System.out.println("There are no patients in the record currently.");
return;
}
for (int i = 0; i < patients.size(); i++) {
Patient currentPatient = patients.get(i);
String patientNRIC = currentPatient.nric;
if (patientNRIC.equals(nric)) {
this.patients.remove(i);
System.out.println("Patient " + currentPatient.name + ", " + patientNRIC + ", has been deleted.");
break;
}
}
if (patients.size() == initialPatientSize) {
System.out.println("Patient " + nric + " not found");
}
}

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package BookBob;
package seedu.duke;

import static org.junit.jupiter.api.Assertions.assertTrue;

Expand Down

0 comments on commit 16e1943

Please sign in to comment.