diff --git a/.gitignore b/.gitignore index 29ae561..d28eeb6 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,94 @@ hs_err_pid* /.metadata/ /.recommenders/ + + + + +# Created by https://www.gitignore.io/api/java,eclipse + +### Eclipse ### + +.metadata +bin/ +tmp/ +*.tmp +*.bak +*.swp +*~.nib +local.properties +.settings/ +.loadpath +.recommenders + +# External tool builders +.externalToolBuilders/ + +# Locally stored "Eclipse launch configurations" +*.launch + +# PyDev specific (Python IDE for Eclipse) +*.pydevproject + +# CDT-specific (C/C++ Development Tooling) +.cproject + +# Java annotation processor (APT) +.factorypath + +# PDT-specific (PHP Development Tools) +.buildpath + +# sbteclipse plugin +.target + +# Tern plugin +.tern-project + +# TeXlipse plugin +.texlipse + +# STS (Spring Tool Suite) +.springBeans + +# Code Recommenders +.recommenders/ + +# Scala IDE specific (Scala & Java development for Eclipse) +.cache-main +.scala_dependencies +.worksheet + +### Eclipse Patch ### +# Eclipse Core +.project + +# JDT-specific (Eclipse Java Development Tools) +.classpath + +### Java ### +# Compiled class file +*.class + +# Log file +*.log + +# BlueJ files +*.ctxt + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.jar +*.war +*.ear +*.zip +*.tar.gz +*.rar + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* + +# End of https://www.gitignore.io/api/java,eclipse + diff --git a/.project b/.project index 4ab0f23..8106398 100644 --- a/.project +++ b/.project @@ -5,7 +5,13 @@ + + org.eclipse.jdt.core.javabuilder + + + + org.eclipse.jdt.core.javanature diff --git a/AE1/AssEx1.java b/AE1/com/dmayers/ae/AssEx1.java similarity index 98% rename from AE1/AssEx1.java rename to AE1/com/dmayers/ae/AssEx1.java index 250b88c..6520b10 100644 --- a/AE1/AssEx1.java +++ b/AE1/com/dmayers/ae/AssEx1.java @@ -1,3 +1,4 @@ +package com.dmayers.ae; /* * Main method. 1.) Gets customer name and starting balance from JOptionPane * Create two Model Objects: Wine and Customer Account. diff --git a/AE1/CustomerAccount.java b/AE1/com/dmayers/ae/CustomerAccount.java similarity index 98% rename from AE1/CustomerAccount.java rename to AE1/com/dmayers/ae/CustomerAccount.java index db7211d..ad2689b 100644 --- a/AE1/CustomerAccount.java +++ b/AE1/com/dmayers/ae/CustomerAccount.java @@ -1,3 +1,4 @@ +package com.dmayers.ae; /* Model class to define Customer account. Stores customer name * current balance, and performs operations to balance to update * instance var: int current balance, string customerName diff --git a/AE1/LWMGUI.java b/AE1/com/dmayers/ae/LWMGUI.java similarity index 90% rename from AE1/LWMGUI.java rename to AE1/com/dmayers/ae/LWMGUI.java index 1f65a95..610aff5 100644 --- a/AE1/LWMGUI.java +++ b/AE1/com/dmayers/ae/LWMGUI.java @@ -1,3 +1,4 @@ +package com.dmayers.ae; /* * User Interface, handle events=View/Controller Class * -Veiw in constructor-controller: actionPerformed @@ -150,35 +151,30 @@ private void layoutComponents() public void actionPerformed(ActionEvent decideWhichAction) { - String tempAmountText = amountText.getText().trim(); + String amountTextString = amountText.getText().trim(); String name = nameText.getText(); - Double price = Double.parseDouble(priceText.getText()); - int amount = Integer.parseInt(amountText.getText()); + String tempPrice = priceText.getText().trim(); //because you were trying to parse here it was throwing the exception + //and stopping your code before it even got to your try catch blocks - Wine wine = new Wine(name,price,amount); + int amount = 0; + double price = 0.0; - //If amount is not an integer, throw error--THIS DOES NOT WORK + //If amount is not an integer, throw error--should work now try { - amount = Integer.parseInt(tempAmountText); + amount = Integer.parseInt(amountTextString); + price = Double.parseDouble(tempPrice); + } catch(NumberFormatException wrongFormat) { - JOptionPane.showMessageDialog(null, "Incorrect information provided."); - } - - //Get price text from string to double - String tempPrice = priceText.getText().trim(); - try - { - price = Double.parseDouble(tempPrice); - } - catch(NumberFormatException priceException) - { - JOptionPane.showMessageDialog(null, "Incorrect information provided. Please try again"); - System.err.println("Not a double"); + JOptionPane.showMessageDialog(null, "Incorrect information provided."); // now we try to parse and if we can't we do something + //if we can then all is good and we can create wine + //(though not sure why you're creating wine...) } + Wine wine = new Wine(name,price,amount); + //Process Sale if (decideWhichAction.getSource()==saleButton) { diff --git a/AE1/Wine.java b/AE1/com/dmayers/ae/Wine.java similarity index 96% rename from AE1/Wine.java rename to AE1/com/dmayers/ae/Wine.java index 0b51260..e44d464 100644 --- a/AE1/Wine.java +++ b/AE1/com/dmayers/ae/Wine.java @@ -1,3 +1,4 @@ +package com.dmayers.ae; /* * Model Class * represented info about type of wine involved in transaction