commit
8d4c001186
@ -0,0 +1,3 @@
|
|||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" project-jdk-name="18" project-jdk-type="JavaSDK">
|
||||||
|
<output url="file://$PROJECT_DIR$/out" />
|
||||||
|
</component>
|
||||||
|
</project>
|
@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/cmpt213.assignment1.packagedeliveriestracker.iml" filepath="$PROJECT_DIR$/cmpt213.assignment1.packagedeliveriestracker.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
@ -0,0 +1,11 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="JAVA_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||||
|
<exclude-output />
|
||||||
|
<content url="file://$MODULE_DIR$">
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||||
|
</content>
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
</component>
|
||||||
|
</module>
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,37 @@
|
|||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Scanner;
|
||||||
|
|
||||||
|
public class Main {
|
||||||
|
|
||||||
|
private static ArrayList<PackageInfo> packageList=new ArrayList<>();
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
TextMenu menu=new TextMenu();
|
||||||
|
do{
|
||||||
|
menu.display();
|
||||||
|
System.out.println("choose an option between 1 and 7:");
|
||||||
|
Scanner scan = new Scanner(System.in);
|
||||||
|
int option=Integer.parseInt(scan.nextLine());
|
||||||
|
if (option > 7 || option < 1){
|
||||||
|
System.out.println("invalid input");
|
||||||
|
}
|
||||||
|
else if(option == 7){
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
switch(option){
|
||||||
|
case 1: menu.list(packageList);
|
||||||
|
case 2: menu.add(packageList);
|
||||||
|
case 3: menu.remove(packageList);
|
||||||
|
case 4: menu.overDueList(packageList);
|
||||||
|
case 5: menu.upcomingList(packageList);
|
||||||
|
case 6: menu.markDelivered(packageList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while (true);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,23 @@
|
|||||||
|
import java.text.DateFormat;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
|
public class PackageInfo {
|
||||||
|
private String name;
|
||||||
|
private String note;
|
||||||
|
private double price;
|
||||||
|
private double weight;
|
||||||
|
private boolean delivered;
|
||||||
|
private LocalDateTime expectedDate;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
DateFormat date = new SimpleDateFormat("yyyy-mm-dd hh:mm");
|
||||||
|
//date.setCalendar(expectedDate);
|
||||||
|
String isDelivered = delivered ? "yes" : "no";
|
||||||
|
//add remaining date
|
||||||
|
return "Name: " + name + "\n" + "Notes: " + note + "\n" + "Price: " + price + "\n" + "Weight: " + weight + "\n" + "Expected Delivery Date: " + expectedDate + "\n" + "Delivered? " + isDelivered;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,80 @@
|
|||||||
|
import java.text.DateFormat;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.time.DateTimeException;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.format.DateTimeParseException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.Scanner;
|
||||||
|
|
||||||
|
public class TextMenu {
|
||||||
|
private final String title = "title";
|
||||||
|
private final String[] options = new String []{
|
||||||
|
"List of all packages",
|
||||||
|
"Add a package",
|
||||||
|
"remove a package",
|
||||||
|
"list overdue packages",
|
||||||
|
"List upcoming packages",
|
||||||
|
"mark package as delivered",
|
||||||
|
"exit"};
|
||||||
|
|
||||||
|
public void display(){
|
||||||
|
int tag = title.length();
|
||||||
|
for (int i=0; i<= tag+3; i++){
|
||||||
|
System.out.print("#");
|
||||||
|
}
|
||||||
|
System.out.println("\n# " + title + " #");
|
||||||
|
for (int i=0; i<= tag+3; i++){
|
||||||
|
System.out.print("#");
|
||||||
|
}
|
||||||
|
DateFormat today = new SimpleDateFormat("yyyy-mm-dd");
|
||||||
|
Calendar cal=Calendar.getInstance();
|
||||||
|
System.out.println("\nToday is: " + today.format(cal.getTime()));
|
||||||
|
for (int i = 0; i < options.length; i++){
|
||||||
|
System.out.println(i+1 + ": " + options[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void list(ArrayList<PackageInfo> packageList){
|
||||||
|
|
||||||
|
}
|
||||||
|
public void add(ArrayList<PackageInfo> packageList){
|
||||||
|
Scanner scan = new Scanner(System.in);
|
||||||
|
String pName;
|
||||||
|
do {
|
||||||
|
System.out.println("enter package a valid name:");
|
||||||
|
pName = scan.nextLine();
|
||||||
|
}
|
||||||
|
while (pName.length()==0);
|
||||||
|
System.out.println("notes:");
|
||||||
|
String pNotes = scan.nextLine();
|
||||||
|
boolean checkDate = false;
|
||||||
|
while (checkDate == false) {
|
||||||
|
try {
|
||||||
|
System.out.println("enter date as yyyy-mm-dd hh-mm:");
|
||||||
|
LocalDateTime pDate = LocalDateTime.parse(scan.nextLine());
|
||||||
|
} catch (DateTimeParseException e) {
|
||||||
|
System.out.println("invalid date format");
|
||||||
|
}
|
||||||
|
checkDate = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void remove(ArrayList<PackageInfo> packageList){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void overDueList(ArrayList<PackageInfo> packageList){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void upcomingList(ArrayList<PackageInfo> packageList){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void markDelivered(ArrayList<PackageInfo> packageList){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in new issue