Skip to content
Open
19 changes: 19 additions & 0 deletions Leos/.classpath
Original file line number Diff line number Diff line change
@@ -1,6 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="lib"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<classpathentry kind="lib" path="lib/commons-codec-1.10.jar"/>
<classpathentry kind="lib" path="lib/commons-collections4-4.1.jar"/>
<classpathentry kind="lib" path="lib/commons-logging-1.2.jar"/>
<classpathentry kind="lib" path="lib/curvesapi-1.04.jar"/>
<classpathentry kind="lib" path="lib/junit-4.12.jar"/>
<classpathentry kind="lib" path="lib/log4j-1.2.17.jar"/>
<classpathentry kind="lib" path="lib/poi-3.15.jar"/>
<classpathentry kind="lib" path="lib/poi-examples-3.15.jar"/>
<classpathentry kind="lib" path="lib/poi-excelant-3.15.jar"/>
<classpathentry kind="lib" path="lib/poi-ooxml-3.15.jar"/>
<classpathentry kind="lib" path="lib/poi-ooxml-schemas-3.15.jar"/>
<classpathentry kind="lib" path="lib/poi-scratchpad-3.15.jar"/>
<classpathentry kind="lib" path="lib/xmlbeans-2.6.0.jar"/>
<classpathentry kind="lib" path="C:/Users/bhavi/Desktop/poi-3.15/poi-examples-3.15.jar"/>
<classpathentry kind="lib" path="C:/Users/bhavi/Desktop/poi-3.15/poi-excelant-3.15.jar"/>
<classpathentry kind="lib" path="C:/Users/bhavi/Desktop/poi-3.15/poi-ooxml-3.15.jar"/>
<classpathentry kind="lib" path="C:/Users/bhavi/Desktop/poi-3.15/poi-ooxml-schemas-3.15.jar"/>
<classpathentry kind="lib" path="C:/Users/bhavi/Desktop/poi-3.15/poi-scratchpad-3.15.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Binary file added Leos/lib/commons-codec-1.10.jar
Binary file not shown.
Binary file added Leos/lib/commons-collections4-4.1.jar
Binary file not shown.
Binary file added Leos/lib/commons-logging-1.2.jar
Binary file not shown.
Binary file added Leos/lib/curvesapi-1.04.jar
Binary file not shown.
Binary file added Leos/lib/junit-4.12.jar
Binary file not shown.
Binary file added Leos/lib/log4j-1.2.17.jar
Binary file not shown.
Binary file added Leos/lib/poi-3.15.jar
Binary file not shown.
Binary file added Leos/lib/poi-examples-3.15.jar
Binary file not shown.
Binary file added Leos/lib/poi-excelant-3.15.jar
Binary file not shown.
Binary file added Leos/lib/poi-ooxml-3.15.jar
Binary file not shown.
Binary file added Leos/lib/poi-ooxml-schemas-3.15.jar
Binary file not shown.
Binary file added Leos/lib/poi-scratchpad-3.15.jar
Binary file not shown.
Binary file added Leos/lib/xmlbeans-2.6.0.jar
Binary file not shown.
32 changes: 32 additions & 0 deletions Leos/src/AvailabilityTime.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import java.sql.Time;;

public class AvailabilityTime {
WorkingTime start;
WorkingTime end;

public AvailabilityTime() {
this.start = null;
this.end = null;
}

public AvailabilityTime(WorkingTime start, WorkingTime end) {
this.start = start;
this.end = end;
}

public WorkingTime getStart() {
return start;
}

public void setStart(WorkingTime start) {
this.start = start;
}

public WorkingTime getEnd() {
return end;
}

public void setEnd(WorkingTime end) {
this.end = end;
}
}
110 changes: 110 additions & 0 deletions Leos/src/Employee.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
import java.util.HashMap;

import javax.management.timer.Timer;

import org.omg.PortableServer.ServantActivator;

import java.security.spec.ECPrivateKeySpec;
import java.sql.Time;
import java.time.*;

public class Employee {
private String name;
private boolean canWorkMonday = false;
private boolean canWorkTuesday = false;
private boolean canWorkWednesday = false;
private boolean canWorkThursday = false;
private boolean canWorkFriday = false;
private boolean canWorkSaturday = false;
private boolean canWorkOvernight = false;
private HashMap<DayOfWeek, AvailabilityTime> availability;

public Employee(String name, String availablility) {
this.name = name;
String[] days = availablility.split(", ");
for(String day: days){
if(day.contains("-")){
parseRange();
} else {
String[] b = day.split(" ");
parseAvailability(b);
}
}
}

public void parseRange(){
canWorkMonday = true;
canWorkTuesday = true;
canWorkWednesday = true;
canWorkThursday = true;
canWorkFriday = true;
}

public void parseAvailability(String[] a){
DayOfWeek day = null;
for (int i = 0; i < a.length; i++){
switch (a[i]){
case "Monday":
canWorkMonday = true;
break;
case "Tuesday":
canWorkTuesday = true;
break;
case "Wednesday":
canWorkWednesday = true;
break;
case "Thursday":
canWorkThursday = true;
break;
case "Friday":
canWorkFriday = true;
break;
case "Saturday":
canWorkSaturday = true;
break;
default:
checkOvernight(a[i]);
break;
}
}
}

private void checkOvernight(String a){
if(a.equals("overnight")){
canWorkOvernight = true;
} else if (a.equals("no")) {
canWorkOvernight = false;
}
}

public boolean isCanWorkMonday() {
return canWorkMonday;
}

public boolean isCanWorkTuesday() {
return canWorkTuesday;
}

public boolean isCanWorkWednesday() {
return canWorkWednesday;
}

public boolean isCanWorkThursday() {
return canWorkThursday;
}

public boolean isCanWorkFriday() {
return canWorkFriday;
}

public boolean isCanWorkSaturday() {
return canWorkSaturday;
}

public boolean isCanWorkOvernight() {
return canWorkOvernight;
}

public static void main(String[] args){
}
}
152 changes: 150 additions & 2 deletions Leos/src/GUI.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,152 @@
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.IOException;
import javax.swing.*;
import javax.swing.filechooser.FileNameExtensionFilter;

public class GUI {

@SuppressWarnings("serial")
public class GUI extends JFrame{
private JTextArea textArea;
private JMenuItem importEmployees;
private JMenuItem importStock;
private JMenuItem exportStock;
private JMenuItem exportEmployees;
private JMenuItem viewEmployees;
private JMenuItem viewStock;
private JButton notificationButton;

public GUI()
{
textArea = new JTextArea();
importEmployees = new JMenuItem("Employees");
importStock = new JMenuItem("Stock");
exportStock = new JMenuItem("Stock");
exportEmployees = new JMenuItem("Employees");
viewStock = new JMenuItem("Stock");
viewEmployees = new JMenuItem("Employees");
notificationButton = new JButton();

JMenuBar menu = new JMenuBar();
JMenu fileMenu = new JMenu("File");
JMenu viewMenu = new JMenu("View");
JMenu importMenu = new JMenu("Import");
JMenu exportMenu = new JMenu("Export");

menu.add(fileMenu);
menu.add(viewMenu);
fileMenu.add(importMenu);
fileMenu.add(exportMenu);
importMenu.add(importEmployees);
importMenu.add(importStock);
exportMenu.add(exportEmployees);
exportMenu.add(exportStock);
viewMenu.add(viewEmployees);
viewMenu.add(viewStock);

this.setSize(600, 400);

JSplitPane pane = new JSplitPane();
pane.setOrientation(JSplitPane.VERTICAL_SPLIT);
pane.setDividerSize(1);
System.out.println();
pane.setDividerLocation((int)(this.getHeight()*0.75));
pane.setTopComponent(textArea);
pane.setBottomComponent(notificationButton);

notificationButton.setSize(50, 50);
pane.setEnabled(false);
textArea.setEditable(false);

this.setJMenuBar(menu);
this.add(pane);

this.setVisible(true);
}

private File saveFile(String title)
{
JFileChooser fileSaver = new JFileChooser();
fileSaver.setDialogTitle(title);
fileSaver.setDialogType(JFileChooser.SAVE_DIALOG);
fileSaver.setFileFilter(new FileNameExtensionFilter("Comma Seperated Values (.csv)", "csv"));
if (fileSaver.showSaveDialog(fileSaver) == JFileChooser.APPROVE_OPTION) {
return fileSaver.getSelectedFile();
}
else
{
return null;
}
}

private File getFile(String title)
{
JFileChooser fileFinder = new JFileChooser();
fileFinder.setDialogTitle(title);
fileFinder.setFileSelectionMode(JFileChooser.FILES_ONLY);
fileFinder.setDialogType(JFileChooser.OPEN_DIALOG);
fileFinder.setFileFilter(new FileNameExtensionFilter("Microsoft Word Document(.docx)", "docx"));
if (fileFinder.showOpenDialog(fileFinder) == JFileChooser.APPROVE_OPTION) {
return fileFinder.getSelectedFile();
}
else
{
return null;
}
}

private void setUpButtons()
{
importEmployees.addActionListener(new ActionListener()
{
@Override
public void actionPerformed(ActionEvent e)
{
File file = getFile("Import Employee");
if(file == null) return;
textArea.append(file.getName() + " has been imported to the employee list. \n");
}
});
importStock.addActionListener(new ActionListener()
{
@Override
public void actionPerformed(ActionEvent e)
{
File file = getFile("Import Stock");
if(file == null) return;
textArea.append(file.getName() + " has been imported to the stock. \n");
}
});
exportEmployees.addActionListener(new ActionListener()
{
@Override
public void actionPerformed(ActionEvent e)
{
File file = saveFile("Export Employees");
try {
file.createNewFile();
} catch (IOException e1) {
e1.printStackTrace();
}
if(file == null) return;
textArea.append(file.getName() + " has been exported. \n");
}
});
exportStock.addActionListener(new ActionListener()
{
@Override
public void actionPerformed(ActionEvent e)
{
File file = saveFile("Export Employees");
if(file == null) return;
textArea.append(file.getName() + " has been exported. \n");
}
});
}

public static void main(String args[])
{
GUI gui = new GUI();
gui.setUpButtons();
}
}
63 changes: 63 additions & 0 deletions Leos/src/Item.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import java.text.DateFormat;
import java.text.ParseException;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.Locale;
import java.text.SimpleDateFormat;



/**
* Items in the store
* @author dan
*
*/
public class Item {
private String name;
private LocalDate expirydate;
private int quantity;
private int popularity;

public Item(String name, String expirydate, int quantity){
this(name,expirydate);
this.quantity = quantity;
this.popularity = 0;
}

public Item(String name, String expirydate){
this.name = name;
this.expirydate = convertDate(expirydate);
this.popularity = 0;
}
public Item(){}
private LocalDate convertDate(String date){
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MMM d, yyyy");
formatter = formatter.withLocale(Locale.US);
LocalDate d = LocalDate.parse(date, formatter);
return d;
}

public LocalDate getExpirydate() {
return expirydate;
}

public void setExpirydate(LocalDate expirydate) {
this.expirydate = expirydate;
}

public int getQuantity() {
return quantity;
}

public void decrementQuantity() {
quantity--;
popularity++;
}

public static void main(String args[]){
//Item t = new Item();
//LocalDate d = t.convertDate("Jun 16, 2018");
//System.out.println(d);
}
}
Loading