diff --git a/PR2 KI Projekt/fakturama_data.xml b/PR2 KI Projekt/fakturama_data.xml
new file mode 100644
index 0000000..778b1ba
--- /dev/null
+++ b/PR2 KI Projekt/fakturama_data.xml
@@ -0,0 +1,58 @@
+
+
+
+
+ Athar
+ Adam
+ Ali
+ false
+ false
+
+
+
+
+ 1
+ Milch
+ 1
+ 2.0
+ 3.0
+
+
+
+
+ 1
+ Athar
+ 23.05.2024
+ Rechnung erstellt
+
+
+ 1
+
+
+
+
+
+
+ 1
+ 1
+ 24.05.2023
+ Rechnung erstellt
+
+
+
+
+ 1
+ 1
+ 23.05.2023
+ Rechnung erstellt
+
+
+
+
+ 1
+ 1
+ 23.05.2023
+ Rechnung erstellt
+
+
+
diff --git a/PR2 KI Projekt/src/FakturamaGUI.java b/PR2 KI Projekt/src/FakturamaGUI.java
index 13f1b6e..ff01721 100644
--- a/PR2 KI Projekt/src/FakturamaGUI.java
+++ b/PR2 KI Projekt/src/FakturamaGUI.java
@@ -1,10 +1,13 @@
import javax.swing.*;
import java.awt.*;
+import java.awt.event.*;
import java.util.ArrayList;
import java.util.List;
public class FakturamaGUI {
private JFrame frame;
+ private JPanel mainPanel;
+ private CardLayout cardLayout;
private JTextArea textArea;
public FakturamaGUI() {
@@ -15,7 +18,17 @@ public class FakturamaGUI {
frame = new JFrame("Fakturama");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(800, 600);
- frame.setLayout(new BorderLayout());
+
+ cardLayout = new CardLayout();
+ mainPanel = new JPanel(cardLayout);
+
+ // Startseite
+ JPanel homePanel = new JPanel(new BorderLayout());
+ textArea = new JTextArea();
+ textArea.setEditable(false);
+ JScrollPane scrollPane = new JScrollPane(textArea);
+ homePanel.add(scrollPane, BorderLayout.CENTER);
+ mainPanel.add(homePanel, "Home");
// Menüleiste
JMenuBar menuBar = new JMenuBar();
@@ -53,6 +66,7 @@ public class FakturamaGUI {
saveDataItem.addActionListener(e -> {
Main.saveData();
updateTextArea();
+ cardLayout.show(mainPanel, "Home");
});
JMenuItem loadDataItem = new JMenuItem("Daten laden");
@@ -60,23 +74,20 @@ public class FakturamaGUI {
loadDataItem.addActionListener(e -> {
Main.loadData();
updateTextArea();
+ cardLayout.show(mainPanel, "Home");
});
JMenuItem exitItem = new JMenuItem("Beenden");
menu.add(exitItem);
exitItem.addActionListener(e -> System.exit(0));
- textArea = new JTextArea();
- textArea.setEditable(false);
- JScrollPane scrollPane = new JScrollPane(textArea);
- frame.add(scrollPane, BorderLayout.CENTER);
-
+ frame.add(mainPanel);
frame.setVisible(true);
updateTextArea();
}
private void showAddCustomerPanel() {
- JPanel panel = new JPanel(new GridLayout(6, 2));
+ JPanel panel = new JPanel(new GridLayout(7, 2));
JLabel nameLabel = new JLabel("Name:");
JTextField nameField = new JTextField();
JLabel addressLabel = new JLabel("Adresse:");
@@ -98,11 +109,11 @@ public class FakturamaGUI {
boolean smallBusiness = smallBusinessBox.isSelected();
Main.customers.add(new Main.Customer(name, address, contactPerson, taxExempt, smallBusiness));
updateTextArea();
+ cardLayout.show(mainPanel, "Home");
});
JButton backButton = new JButton("Zurück");
- backButton.setBackground(new Color(255, 182, 193)); // Hellrot
- backButton.addActionListener(e -> updateTextArea());
+ backButton.addActionListener(e -> cardLayout.show(mainPanel, "Home"));
panel.add(nameLabel);
panel.add(nameField);
@@ -114,14 +125,15 @@ public class FakturamaGUI {
panel.add(taxExemptBox);
panel.add(smallBusinessLabel);
panel.add(smallBusinessBox);
- panel.add(addButton);
panel.add(backButton);
+ panel.add(addButton);
- showPanel(panel);
+ mainPanel.add(panel, "AddCustomer");
+ cardLayout.show(mainPanel, "AddCustomer");
}
private void showAddArticlePanel() {
- JPanel panel = new JPanel(new GridLayout(5, 2));
+ JPanel panel = new JPanel(new GridLayout(6, 2));
JLabel unitLabel = new JLabel("Einheit:");
JTextField unitField = new JTextField();
JLabel descriptionLabel = new JLabel("Bezeichnung:");
@@ -129,7 +141,7 @@ public class FakturamaGUI {
JLabel netPriceLabel = new JLabel("Nettopreis:");
JTextField netPriceField = new JTextField();
JLabel vatRateLabel = new JLabel("Mehrwertsteuersatz:");
- JTextField vatRateField = new JTextField();
+ JComboBox vatRateBox = new JComboBox<>(new Double[]{7.0, 19.0});
JButton addButton = new JButton("Hinzufügen");
addButton.setBackground(new Color(144, 238, 144)); // Hellgrün
@@ -137,14 +149,14 @@ public class FakturamaGUI {
String unit = unitField.getText();
String description = descriptionField.getText();
double netPrice = Double.parseDouble(netPriceField.getText());
- double vatRate = Double.parseDouble(vatRateField.getText());
+ double vatRate = (Double) vatRateBox.getSelectedItem();
Main.articles.add(new Main.Article(unit, description, netPrice, vatRate));
updateTextArea();
+ cardLayout.show(mainPanel, "Home");
});
JButton backButton = new JButton("Zurück");
- backButton.setBackground(new Color(255, 182, 193)); // Hellrot
- backButton.addActionListener(e -> updateTextArea());
+ backButton.addActionListener(e -> cardLayout.show(mainPanel, "Home"));
panel.add(unitLabel);
panel.add(unitField);
@@ -153,36 +165,42 @@ public class FakturamaGUI {
panel.add(netPriceLabel);
panel.add(netPriceField);
panel.add(vatRateLabel);
- panel.add(vatRateField);
- panel.add(addButton);
+ panel.add(vatRateBox);
panel.add(backButton);
+ panel.add(addButton);
- showPanel(panel);
+ mainPanel.add(panel, "AddArticle");
+ cardLayout.show(mainPanel, "AddArticle");
}
private void showCreateOfferPanel() {
JPanel panel = new JPanel(new BorderLayout());
- JPanel formPanel = new JPanel(new GridLayout(4, 2));
+ JPanel formPanel = new JPanel(new GridLayout(4, 2));
JLabel customerLabel = new JLabel("Kunde:");
JComboBox customerBox = new JComboBox<>();
for (Main.Customer customer : Main.customers) {
customerBox.addItem(customer.name);
}
+ formPanel.add(customerLabel);
+ formPanel.add(customerBox);
JLabel dateLabel = new JLabel("Datum:");
JTextField dateField = new JTextField();
-
- formPanel.add(customerLabel);
- formPanel.add(customerBox);
formPanel.add(dateLabel);
formPanel.add(dateField);
+ panel.add(formPanel, BorderLayout.NORTH);
+
JLabel articlesLabel = new JLabel("Artikel:");
JList articlesList = new JList<>(Main.articles.stream().map(a -> a.description).toArray(String[]::new));
articlesList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
JScrollPane articlesScrollPane = new JScrollPane(articlesList);
+ panel.add(articlesLabel, BorderLayout.CENTER);
+ panel.add(articlesScrollPane, BorderLayout.CENTER);
+
+ JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
JButton addButton = new JButton("Erstellen");
addButton.setBackground(new Color(144, 238, 144)); // Hellgrün
addButton.addActionListener(e -> {
@@ -196,26 +214,24 @@ public class FakturamaGUI {
String date = dateField.getText();
Main.offers.add(new Main.Offer(Main.nextOfferId++, customer, selectedArticles, date, "Angebot erstellt"));
updateTextArea();
+ cardLayout.show(mainPanel, "Home");
});
JButton backButton = new JButton("Zurück");
- backButton.setBackground(new Color(255, 182, 193)); // Hellrot
- backButton.addActionListener(e -> updateTextArea());
+ backButton.addActionListener(e -> cardLayout.show(mainPanel, "Home"));
- JPanel buttonPanel = new JPanel(new GridLayout(1, 2));
- buttonPanel.add(addButton);
buttonPanel.add(backButton);
+ buttonPanel.add(addButton);
- panel.add(formPanel, BorderLayout.NORTH);
- panel.add(articlesLabel, BorderLayout.CENTER);
- panel.add(articlesScrollPane, BorderLayout.CENTER);
panel.add(buttonPanel, BorderLayout.SOUTH);
- showPanel(panel);
+ mainPanel.add(panel, "CreateOffer");
+ cardLayout.show(mainPanel, "CreateOffer");
}
+
private void showCreateOrderConfirmationPanel() {
- JPanel panel = new JPanel(new GridLayout(4, 2));
+ JPanel panel = new JPanel(new GridLayout(6, 2));
JLabel offerLabel = new JLabel("Angebot:");
JComboBox offerBox = new JComboBox<>();
for (Main.Offer offer : Main.offers) {
@@ -234,24 +250,27 @@ public class FakturamaGUI {
Main.orderConfirmations.add(new Main.OrderConfirmation(Main.nextOrderConfirmationId++, selectedOffer, date, "Auftragsbestätigung erstellt"));
selectedOffer.status = "Auftragsbestätigung erstellt";
updateTextArea();
+ cardLayout.show(mainPanel, "Home");
});
JButton backButton = new JButton("Zurück");
- backButton.setBackground(new Color(255, 182, 193)); // Hellrot
- backButton.addActionListener(e -> updateTextArea());
+ backButton.addActionListener(e -> cardLayout.show(mainPanel, "Home"));
panel.add(offerLabel);
panel.add(offerBox);
panel.add(dateLabel);
panel.add(dateField);
- panel.add(addButton);
+ panel.add(new JLabel());
+ panel.add(new JLabel());
panel.add(backButton);
+ panel.add(addButton);
- showPanel(panel);
+ mainPanel.add(panel, "CreateOrderConfirmation");
+ cardLayout.show(mainPanel, "CreateOrderConfirmation");
}
private void showCreateDeliveryNotePanel() {
- JPanel panel = new JPanel(new GridLayout(4, 2));
+ JPanel panel = new JPanel(new GridLayout(6, 2));
JLabel orderConfirmationLabel = new JLabel("Auftragsbestätigung:");
JComboBox orderConfirmationBox = new JComboBox<>();
for (Main.OrderConfirmation orderConfirmation : Main.orderConfirmations) {
@@ -271,24 +290,27 @@ public class FakturamaGUI {
selectedOrderConfirmation.status = "Lieferschein erstellt";
selectedOrderConfirmation.offer.status = "Lieferschein erstellt";
updateTextArea();
+ cardLayout.show(mainPanel, "Home");
});
JButton backButton = new JButton("Zurück");
- backButton.setBackground(new Color(255, 182, 193)); // Hellrot
- backButton.addActionListener(e -> updateTextArea());
+ backButton.addActionListener(e -> cardLayout.show(mainPanel, "Home"));
panel.add(orderConfirmationLabel);
panel.add(orderConfirmationBox);
panel.add(dateLabel);
panel.add(dateField);
- panel.add(addButton);
+ panel.add(new JLabel());
+ panel.add(new JLabel());
panel.add(backButton);
+ panel.add(addButton);
- showPanel(panel);
+ mainPanel.add(panel, "CreateDeliveryNote");
+ cardLayout.show(mainPanel, "CreateDeliveryNote");
}
private void showCreateInvoicePanel() {
- JPanel panel = new JPanel(new GridLayout(4, 2));
+ JPanel panel = new JPanel(new GridLayout(6, 2));
JLabel deliveryNoteLabel = new JLabel("Lieferschein:");
JComboBox deliveryNoteBox = new JComboBox<>();
for (Main.DeliveryNote deliveryNote : Main.deliveryNotes) {
@@ -309,34 +331,23 @@ public class FakturamaGUI {
selectedDeliveryNote.orderConfirmation.status = "Rechnung erstellt";
selectedDeliveryNote.orderConfirmation.offer.status = "Rechnung erstellt";
updateTextArea();
+ cardLayout.show(mainPanel, "Home");
});
JButton backButton = new JButton("Zurück");
- backButton.setBackground(new Color(255, 182, 193)); // Hellrot
- backButton.addActionListener(e -> updateTextArea());
+ backButton.addActionListener(e -> cardLayout.show(mainPanel, "Home"));
panel.add(deliveryNoteLabel);
panel.add(deliveryNoteBox);
panel.add(dateLabel);
panel.add(dateField);
- panel.add(addButton);
+ panel.add(new JLabel());
+ panel.add(new JLabel());
panel.add(backButton);
+ panel.add(addButton);
- showPanel(panel);
- }
-
- private void showPanel(JPanel panel) {
- frame.getContentPane().removeAll();
- frame.getContentPane().add(panel, BorderLayout.CENTER);
- frame.revalidate();
- frame.repaint();
- }
-
- private void showPanel(JScrollPane scrollPane) {
- frame.getContentPane().removeAll();
- frame.getContentPane().add(scrollPane, BorderLayout.CENTER);
- frame.revalidate();
- frame.repaint();
+ mainPanel.add(panel, "CreateInvoice");
+ cardLayout.show(mainPanel, "CreateInvoice");
}
private void updateTextArea() {
@@ -347,7 +358,7 @@ public class FakturamaGUI {
}
sb.append("\nArtikel:\n");
for (Main.Article article : Main.articles) {
- sb.append(article.description).append(" - ").append(article.unit).append(" - ").append(article.netPrice).append(" € - ").append(article.vatRate).append(" %").append("\n");
+ sb.append(article.id).append(": ").append(article.description).append(" - ").append(article.unit).append(" - ").append(article.netPrice).append(" € - ").append(article.vatRate).append(" %").append("\n");
}
sb.append("\nAngebote:\n");
for (Main.Offer offer : Main.offers) {
@@ -369,7 +380,6 @@ public class FakturamaGUI {
sb.append("Rechnung #").append(invoice.id).append(" - ").append(invoice.deliveryNote.orderConfirmation.offer.customer.name).append(" - ").append(invoice.date).append(" - ").append(invoice.status).append("\n");
}
textArea.setText(sb.toString());
- showPanel(new JScrollPane(textArea));
}
public static void main(String[] args) {
diff --git a/PR2 KI Projekt/src/Main.java b/PR2 KI Projekt/src/Main.java
index aa60b1d..ef47cdc 100644
--- a/PR2 KI Projekt/src/Main.java
+++ b/PR2 KI Projekt/src/Main.java
@@ -665,14 +665,14 @@ public class Main {
for (int i = 0; i < customerList.getLength(); i++) {
Node customerNode = customerList.item(i);
- if (customerNode.getNodeType() == Node.ELEMENT_NODE) {
+ if (customerNode != null && customerNode.getNodeType() == Node.ELEMENT_NODE) {
Element customerElement = (Element) customerNode;
- String name = customerElement.getElementsByTagName("Name").item(0).getTextContent();
- String address = customerElement.getElementsByTagName("Address").item(0).getTextContent();
- String contactPerson = customerElement.getElementsByTagName("ContactPerson").item(0).getTextContent();
- boolean taxExempt = Boolean.parseBoolean(customerElement.getElementsByTagName("TaxExempt").item(0).getTextContent());
- boolean smallBusiness = Boolean.parseBoolean(customerElement.getElementsByTagName("SmallBusiness").item(0).getTextContent());
+ String name = getElementTextContent(customerElement, "Name");
+ String address = getElementTextContent(customerElement, "Address");
+ String contactPerson = getElementTextContent(customerElement, "ContactPerson");
+ boolean taxExempt = Boolean.parseBoolean(getElementTextContent(customerElement, "TaxExempt"));
+ boolean smallBusiness = Boolean.parseBoolean(getElementTextContent(customerElement, "SmallBusiness"));
customers.add(new Customer(name, address, contactPerson, taxExempt, smallBusiness));
}
@@ -684,14 +684,14 @@ public class Main {
for (int i = 0; i < articleList.getLength(); i++) {
Node articleNode = articleList.item(i);
- if (articleNode.getNodeType() == Node.ELEMENT_NODE) {
+ if (articleNode != null && articleNode.getNodeType() == Node.ELEMENT_NODE) {
Element articleElement = (Element) articleNode;
- int id = Integer.parseInt(articleElement.getElementsByTagName("ID").item(0).getTextContent());
- String unit = articleElement.getElementsByTagName("Unit").item(0).getTextContent();
- String description = articleElement.getElementsByTagName("Description").item(0).getTextContent();
- double netPrice = Double.parseDouble(articleElement.getElementsByTagName("NetPrice").item(0).getTextContent());
- double vatRate = Double.parseDouble(articleElement.getElementsByTagName("VatRate").item(0).getTextContent());
+ int id = parseIntOrDefault(getElementTextContent(articleElement, "ID"), -1);
+ String unit = getElementTextContent(articleElement, "Unit");
+ String description = getElementTextContent(articleElement, "Description");
+ double netPrice = parseDoubleOrDefault(getElementTextContent(articleElement, "NetPrice"), 0.0);
+ double vatRate = parseDoubleOrDefault(getElementTextContent(articleElement, "VatRate"), 0.0);
Article article = new Article(unit, description, netPrice, vatRate);
article.id = id; // Set the ID explicitly
@@ -705,15 +705,15 @@ public class Main {
for (int i = 0; i < offerList.getLength(); i++) {
Node offerNode = offerList.item(i);
- if (offerNode.getNodeType() == Node.ELEMENT_NODE) {
+ if (offerNode != null && offerNode.getNodeType() == Node.ELEMENT_NODE) {
Element offerElement = (Element) offerNode;
- int id = Integer.parseInt(offerElement.getElementsByTagName("ID").item(0).getTextContent());
- String customerName = offerElement.getElementsByTagName("CustomerName").item(0).getTextContent();
+ int id = parseIntOrDefault(getElementTextContent(offerElement, "ID"), -1);
+ String customerName = getElementTextContent(offerElement, "CustomerName");
Customer offerCustomer = customers.stream().filter(c -> c.name.equals(customerName)).findFirst().orElse(null);
- String date = offerElement.getElementsByTagName("Date").item(0).getTextContent();
- String status = offerElement.getElementsByTagName("Status").item(0).getTextContent();
+ String date = getElementTextContent(offerElement, "Date");
+ String status = getElementTextContent(offerElement, "Status");
NodeList offerArticles = offerElement.getElementsByTagName("Article");
List offerArticleList = new ArrayList<>();
@@ -721,10 +721,10 @@ public class Main {
for (int j = 0; j < offerArticles.getLength(); j++) {
Node offerArticleNode = offerArticles.item(j);
- if (offerArticleNode.getNodeType() == Node.ELEMENT_NODE) {
+ if (offerArticleNode != null && offerArticleNode.getNodeType() == Node.ELEMENT_NODE) {
Element offerArticleElement = (Element) offerArticleNode;
- int articleId = Integer.parseInt(offerArticleElement.getElementsByTagName("ID").item(0).getTextContent());
+ int articleId = parseIntOrDefault(getElementTextContent(offerArticleElement, "ID"), -1);
Article offerArticle = articles.stream().filter(a -> a.id == articleId).findFirst().orElse(null);
if (offerArticle != null) {
@@ -745,15 +745,15 @@ public class Main {
for (int i = 0; i < orderConfirmationList.getLength(); i++) {
Node orderConfirmationNode = orderConfirmationList.item(i);
- if (orderConfirmationNode.getNodeType() == Node.ELEMENT_NODE) {
+ if (orderConfirmationNode != null && orderConfirmationNode.getNodeType() == Node.ELEMENT_NODE) {
Element orderConfirmationElement = (Element) orderConfirmationNode;
- int id = Integer.parseInt(orderConfirmationElement.getElementsByTagName("ID").item(0).getTextContent());
- int offerId = Integer.parseInt(orderConfirmationElement.getElementsByTagName("OfferID").item(0).getTextContent());
+ int id = parseIntOrDefault(getElementTextContent(orderConfirmationElement, "ID"), -1);
+ int offerId = parseIntOrDefault(getElementTextContent(orderConfirmationElement, "OfferID"), -1);
Offer orderConfirmationOffer = offers.stream().filter(o -> o.id == offerId).findFirst().orElse(null);
- String date = orderConfirmationElement.getElementsByTagName("Date").item(0).getTextContent();
- String status = orderConfirmationElement.getElementsByTagName("Status").item(0).getTextContent();
+ String date = getElementTextContent(orderConfirmationElement, "Date");
+ String status = getElementTextContent(orderConfirmationElement, "Status");
if (orderConfirmationOffer != null) {
orderConfirmations.add(new OrderConfirmation(id, orderConfirmationOffer, date, status));
@@ -767,15 +767,15 @@ public class Main {
for (int i = 0; i < deliveryNoteList.getLength(); i++) {
Node deliveryNoteNode = deliveryNoteList.item(i);
- if (deliveryNoteNode.getNodeType() == Node.ELEMENT_NODE) {
+ if (deliveryNoteNode != null && deliveryNoteNode.getNodeType() == Node.ELEMENT_NODE) {
Element deliveryNoteElement = (Element) deliveryNoteNode;
- int id = Integer.parseInt(deliveryNoteElement.getElementsByTagName("ID").item(0).getTextContent());
- int orderConfirmationId = Integer.parseInt(deliveryNoteElement.getElementsByTagName("OrderConfirmationID").item(0).getTextContent());
+ int id = parseIntOrDefault(getElementTextContent(deliveryNoteElement, "ID"), -1);
+ int orderConfirmationId = parseIntOrDefault(getElementTextContent(deliveryNoteElement, "OrderConfirmationID"), -1);
OrderConfirmation deliveryNoteOrderConfirmation = orderConfirmations.stream().filter(oc -> oc.id == orderConfirmationId).findFirst().orElse(null);
- String date = deliveryNoteElement.getElementsByTagName("Date").item(0).getTextContent();
- String status = deliveryNoteElement.getElementsByTagName("Status").item(0).getTextContent();
+ String date = getElementTextContent(deliveryNoteElement, "Date");
+ String status = getElementTextContent(deliveryNoteElement, "Status");
if (deliveryNoteOrderConfirmation != null) {
deliveryNotes.add(new DeliveryNote(id, deliveryNoteOrderConfirmation, date, status));
@@ -789,15 +789,15 @@ public class Main {
for (int i = 0; i < invoiceList.getLength(); i++) {
Node invoiceNode = invoiceList.item(i);
- if (invoiceNode.getNodeType() == Node.ELEMENT_NODE) {
+ if (invoiceNode != null && invoiceNode.getNodeType() == Node.ELEMENT_NODE) {
Element invoiceElement = (Element) invoiceNode;
- int id = Integer.parseInt(invoiceElement.getElementsByTagName("ID").item(0).getTextContent());
- int deliveryNoteId = Integer.parseInt(invoiceElement.getElementsByTagName("DeliveryNoteID").item(0).getTextContent());
+ int id = parseIntOrDefault(getElementTextContent(invoiceElement, "ID"), -1);
+ int deliveryNoteId = parseIntOrDefault(getElementTextContent(invoiceElement, "DeliveryNoteID"), -1);
DeliveryNote invoiceDeliveryNote = deliveryNotes.stream().filter(dn -> dn.id == deliveryNoteId).findFirst().orElse(null);
- String date = invoiceElement.getElementsByTagName("Date").item(0).getTextContent();
- String status = invoiceElement.getElementsByTagName("Status").item(0).getTextContent();
+ String date = getElementTextContent(invoiceElement, "Date");
+ String status = getElementTextContent(invoiceElement, "Status");
if (invoiceDeliveryNote != null) {
invoices.add(new Invoice(id, invoiceDeliveryNote, date, status));
@@ -811,4 +811,33 @@ public class Main {
e.printStackTrace();
}
}
+
+ private static String getElementTextContent(Element parentElement, String tagName) {
+ NodeList nodeList = parentElement.getElementsByTagName(tagName);
+ if (nodeList != null && nodeList.getLength() > 0) {
+ Node node = nodeList.item(0);
+ if (node != null) {
+ return node.getTextContent();
+ }
+ }
+ return "";
+ }
+
+ private static int parseIntOrDefault(String str, int defaultValue) {
+ try {
+ return Integer.parseInt(str);
+ } catch (NumberFormatException e) {
+ return defaultValue;
+ }
+ }
+
+ private static double parseDoubleOrDefault(String str, double defaultValue) {
+ try {
+ return Double.parseDouble(str);
+ } catch (NumberFormatException e) {
+ return defaultValue;
+ }
+ }
+
+
}