Compare commits
No commits in common. "main" and "master" have entirely different histories.
|
@ -1,181 +1 @@
|
|||
# ---> Java
|
||||
# Compiled class file
|
||||
*.class
|
||||
|
||||
# Log file
|
||||
*.log
|
||||
|
||||
# BlueJ files
|
||||
*.ctxt
|
||||
|
||||
# Mobile Tools for Java (J2ME)
|
||||
.mtj.tmp/
|
||||
|
||||
# Package Files #
|
||||
*.jar
|
||||
*.war
|
||||
*.nar
|
||||
*.ear
|
||||
*.zip
|
||||
*.tar.gz
|
||||
*.rar
|
||||
|
||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||
hs_err_pid*
|
||||
replay_pid*
|
||||
|
||||
# ---> 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
|
||||
|
||||
# CDT- autotools
|
||||
.autotools
|
||||
|
||||
# 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/
|
||||
|
||||
# Annotation Processing
|
||||
.apt_generated/
|
||||
.apt_generated_test/
|
||||
|
||||
# Scala IDE specific (Scala & Java development for Eclipse)
|
||||
.cache-main
|
||||
.scala_dependencies
|
||||
.worksheet
|
||||
|
||||
# Uncomment this line if you wish to ignore the project description file.
|
||||
# Typically, this file would be tracked if it contains build/dependency configurations:
|
||||
#.project
|
||||
|
||||
# ---> VisualStudioCode
|
||||
.vscode/*
|
||||
!.vscode/settings.json
|
||||
!.vscode/tasks.json
|
||||
!.vscode/launch.json
|
||||
!.vscode/extensions.json
|
||||
!.vscode/*.code-snippets
|
||||
|
||||
# Local History for Visual Studio Code
|
||||
.history/
|
||||
|
||||
# Built Visual Studio Code Extensions
|
||||
*.vsix
|
||||
|
||||
# ---> JetBrains
|
||||
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
|
||||
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
||||
|
||||
# User-specific stuff
|
||||
.idea/**/workspace.xml
|
||||
.idea/**/tasks.xml
|
||||
.idea/**/usage.statistics.xml
|
||||
.idea/**/dictionaries
|
||||
.idea/**/shelf
|
||||
|
||||
# AWS User-specific
|
||||
.idea/**/aws.xml
|
||||
|
||||
# Generated files
|
||||
.idea/**/contentModel.xml
|
||||
|
||||
# Sensitive or high-churn files
|
||||
.idea/**/dataSources/
|
||||
.idea/**/dataSources.ids
|
||||
.idea/**/dataSources.local.xml
|
||||
.idea/**/sqlDataSources.xml
|
||||
.idea/**/dynamic.xml
|
||||
.idea/**/uiDesigner.xml
|
||||
.idea/**/dbnavigator.xml
|
||||
|
||||
# Gradle
|
||||
.idea/**/gradle.xml
|
||||
.idea/**/libraries
|
||||
|
||||
# Gradle and Maven with auto-import
|
||||
# When using Gradle or Maven with auto-import, you should exclude module files,
|
||||
# since they will be recreated, and may cause churn. Uncomment if using
|
||||
# auto-import.
|
||||
# .idea/artifacts
|
||||
# .idea/compiler.xml
|
||||
# .idea/jarRepositories.xml
|
||||
# .idea/modules.xml
|
||||
# .idea/*.iml
|
||||
# .idea/modules
|
||||
# *.iml
|
||||
# *.ipr
|
||||
|
||||
# CMake
|
||||
cmake-build-*/
|
||||
|
||||
# Mongo Explorer plugin
|
||||
.idea/**/mongoSettings.xml
|
||||
|
||||
# File-based project format
|
||||
*.iws
|
||||
|
||||
# IntelliJ
|
||||
out/
|
||||
|
||||
# mpeltonen/sbt-idea plugin
|
||||
.idea_modules/
|
||||
|
||||
# JIRA plugin
|
||||
atlassian-ide-plugin.xml
|
||||
|
||||
# Cursive Clojure plugin
|
||||
.idea/replstate.xml
|
||||
|
||||
# SonarLint plugin
|
||||
.idea/sonarlint/
|
||||
|
||||
# Crashlytics plugin (for Android Studio and IntelliJ)
|
||||
com_crashlytics_export_strings.xml
|
||||
crashlytics.properties
|
||||
crashlytics-build.properties
|
||||
fabric.properties
|
||||
|
||||
# Editor-based Rest Client
|
||||
.idea/httpRequests
|
||||
|
||||
# Android studio 3.1+ serialized cache file
|
||||
.idea/caches/build_file_checksums.ser
|
||||
|
||||
/bin/
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
/bin/
|
||||
/.classpath
|
||||
/.project
|
|
@ -0,0 +1 @@
|
|||
/org.eclipse.core.resources.prefs
|
|
@ -0,0 +1,7 @@
|
|||
Name;Beschreibung;Preis;Gewicht;Bestand
|
||||
Gieskanne;Premium Gärtner-Gieskanne;3,99;250,00;17,00
|
||||
Hut;Perfekt für die Hutablage;21,98;120,00;123,00
|
||||
Dosenwurst;LWWRSCHT: das Pfälzer Original, nur kurz im Angebot;3,99;200,00;7,00
|
||||
Gartenschlauch;10 m, dehnbar bis auf die doppelte Länge;18,99;1300,00;23,00
|
||||
Schraubenset;100 zufällig ausgewählte Schrauben;2,99;287,00;99,00
|
||||
Akkuschrauber;Mit extra großem Drehmoment;25,00;900,00;13,00
|
|
|
@ -0,0 +1,13 @@
|
|||
import java.io.FileNotFoundException;
|
||||
|
||||
import de.hs_mannheim.informatik.rhenus.domain.ExceptionsKlassen.KundeNichtGefundenException;
|
||||
import de.hs_mannheim.informatik.rhenus.domain.ExceptionsKlassen.ProduktNichtGefundenException;
|
||||
import de.hs_mannheim.informatik.rhenus.tui.TUI;
|
||||
|
||||
public class Main {
|
||||
|
||||
public static void main(String[] args) throws FileNotFoundException, ProduktNichtGefundenException, KundeNichtGefundenException {
|
||||
new TUI();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package de.hs_mannheim.informatik.rhenus.domain.ExceptionsKlassen;
|
||||
|
||||
public class EmptyInputException extends Exception{
|
||||
|
||||
public EmptyInputException(String error){
|
||||
super(error);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package de.hs_mannheim.informatik.rhenus.domain.ExceptionsKlassen;
|
||||
|
||||
public class KundeNichtGefundenException extends Exception {
|
||||
|
||||
KundeNichtGefundenException(String error){
|
||||
super(error);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package de.hs_mannheim.informatik.rhenus.domain.ExceptionsKlassen;
|
||||
|
||||
public class ProduktNichtGefundenException extends Exception {
|
||||
|
||||
public ProduktNichtGefundenException(String error){
|
||||
super(error);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package de.hs_mannheim.informatik.rhenus.domain;
|
||||
|
||||
public class GesamtKostenBerechnen {
|
||||
|
||||
|
||||
public static double gesamtKosten (Produkt p) {
|
||||
double kosten = 0.0;
|
||||
|
||||
|
||||
return kosten;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package de.hs_mannheim.informatik.rhenus.domain.JTests;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import java.io.FileNotFoundException;
|
||||
import org.junit.jupiter.api.*;
|
||||
import de.hs_mannheim.informatik.rhenus.domain.*;
|
||||
|
||||
class WarenkorbTest {
|
||||
|
||||
|
||||
@Test
|
||||
void test() throws FileNotFoundException {
|
||||
Kaufhalle kaufhalle = new Kaufhalle();
|
||||
|
||||
assertTrue(kaufhalle.produkteLaden());
|
||||
|
||||
|
||||
/*
|
||||
* 1.Produkt: name=Gieskanne, beschreibung=Premium Gärtner-Gieskanne, preis=3.99, gewicht=250, bestand=17
|
||||
2.Produkt: name=Hut, beschreibung=Perfekt für die Hutablage, preis=21.98, gewicht=120, bestand=123
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,81 @@
|
|||
package de.hs_mannheim.informatik.rhenus.domain;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.util.*;
|
||||
import de.hs_mannheim.informatik.rhenus.domain.ExceptionsKlassen.*;
|
||||
|
||||
public class Kaufhalle {
|
||||
private ArrayList<Produkt> produkte;
|
||||
private ArrayList<Kunde> kunden;
|
||||
|
||||
public Kaufhalle() throws FileNotFoundException {
|
||||
this.produkte = new ArrayList<>();
|
||||
this.kunden = new ArrayList<>();
|
||||
}
|
||||
|
||||
public void addProduktZuWarenkorb(String Produktname) throws ProduktNichtGefundenException, KundeNichtGefundenException {
|
||||
Produkt neueProdukt = findeProduktImKaufhalle(Produktname);
|
||||
if (neueProdukt == null)
|
||||
throw new ProduktNichtGefundenException("Produkt ist nicht Verfügbar!");
|
||||
|
||||
|
||||
}
|
||||
|
||||
private Kunde findKunde(String kundeName) {
|
||||
for (Kunde kunde : kunden)
|
||||
if (kunde.getName().equalsIgnoreCase(kundeName))
|
||||
return kunde;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public boolean produkteLaden() throws FileNotFoundException {
|
||||
Scanner sc = new Scanner(
|
||||
new File("C:\\Users\\obaya\\git\\OnlineShop2024\\OnlineShop2024\\resources\\produkte.csv"));
|
||||
|
||||
int cnt = 0;
|
||||
while (sc.hasNextLine()) {
|
||||
String produkt = sc.nextLine();
|
||||
|
||||
if (produkt.startsWith("Name"))
|
||||
continue;
|
||||
|
||||
String[] spalten = produkt.split(";");
|
||||
spalten[2] = spalten[2].replaceAll(",", ".");
|
||||
spalten[3] = spalten[3].substring(0, spalten[3].indexOf(","));
|
||||
spalten[4] = spalten[4].substring(0, spalten[4].indexOf(","));
|
||||
|
||||
produkte.add(new Produkt(spalten[0], spalten[1], Float.parseFloat(spalten[2]), Integer.parseInt(spalten[3]),
|
||||
Integer.parseInt(spalten[4])));
|
||||
cnt++;
|
||||
}
|
||||
|
||||
sc.close();
|
||||
return true;
|
||||
}
|
||||
|
||||
public ArrayList<String> zeigeProdukte() {
|
||||
ArrayList<String> allProdukte = new ArrayList<>();
|
||||
int index = 1;
|
||||
for (Produkt p : produkte)
|
||||
allProdukte.add(index++ + ".Produkt: " + p.print());
|
||||
|
||||
return allProdukte;
|
||||
}
|
||||
|
||||
private Produkt findeProduktImKaufhalle(String name) {
|
||||
|
||||
for (Produkt p : produkte)
|
||||
if (p.getName().equalsIgnoreCase(name))
|
||||
return p;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
package de.hs_mannheim.informatik.rhenus.domain;
|
||||
|
||||
public class Kunde {
|
||||
|
||||
private String name;
|
||||
private String anschrift;
|
||||
private Warenkorb warenKorb;
|
||||
private double produktKosten;
|
||||
private static int UserID = 100;
|
||||
private int ID;
|
||||
|
||||
public Kunde(String name, String anschrift) {
|
||||
this.name = name;
|
||||
this.anschrift = anschrift;
|
||||
this.ID = UserID++;
|
||||
this.produktKosten = 0.0;
|
||||
this.warenKorb = new Warenkorb();
|
||||
}
|
||||
|
||||
public Kunde() {
|
||||
this(null,null);
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getAnschrift() {
|
||||
return anschrift;
|
||||
}
|
||||
|
||||
public void setAnschrift(String anschrift) {
|
||||
this.anschrift = anschrift;
|
||||
}
|
||||
|
||||
public Warenkorb getWarenKorb() {
|
||||
return warenKorb;
|
||||
}
|
||||
|
||||
public int getID() {
|
||||
return ID;
|
||||
}
|
||||
|
||||
public double getProduktKosten() {
|
||||
return produktKosten;
|
||||
}
|
||||
|
||||
public void setProduktKosten(double produktKosten) {
|
||||
this.produktKosten = produktKosten;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
package de.hs_mannheim.informatik.rhenus.domain;
|
||||
|
||||
public class Produkt {
|
||||
private String name;
|
||||
private String beschreibung;
|
||||
private double preis;
|
||||
private int gewicht;
|
||||
private int bestand;
|
||||
|
||||
public Produkt(String name, String beschreibung, double preis, int gewicht, int bestand) {
|
||||
|
||||
this.name = name;
|
||||
this.beschreibung = beschreibung;
|
||||
this.preis = preis;
|
||||
this.gewicht = gewicht;
|
||||
this.bestand = bestand;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getBeschreibung() {
|
||||
return beschreibung;
|
||||
}
|
||||
|
||||
public double getPreis() {
|
||||
return preis;
|
||||
}
|
||||
|
||||
public int getGewicht() {
|
||||
return gewicht;
|
||||
}
|
||||
|
||||
public int getBestand() {
|
||||
return bestand;
|
||||
}
|
||||
|
||||
|
||||
public String print() {
|
||||
return "name=" + name + ", beschreibung=" + beschreibung + ", preis=" + preis + ", gewicht=" + gewicht
|
||||
+ ", bestand=" + bestand;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
package de.hs_mannheim.informatik.rhenus.domain;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class Warenkorb {
|
||||
private ArrayList<Produkt> produkte;
|
||||
private int anzahlProdkute;
|
||||
|
||||
Warenkorb() {
|
||||
produkte = new ArrayList<>();
|
||||
}
|
||||
|
||||
public boolean addProdukt(Produkt neueProdukt) {
|
||||
|
||||
produkte.add(neueProdukt);
|
||||
anzahlProdkute++;
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean loescheprodukt(String name) {
|
||||
Produkt produktZuLoeschen = findeProduktImWarenkorb(name);
|
||||
if (produktZuLoeschen == null)
|
||||
return false;
|
||||
|
||||
anzahlProdkute--;
|
||||
return true;
|
||||
}
|
||||
|
||||
private Produkt findeProduktImWarenkorb(String name) {
|
||||
|
||||
for (Produkt p : produkte)
|
||||
if (p.getName().equalsIgnoreCase(name))
|
||||
return p;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public ArrayList<String> zeigeProdukteImWarenKorb() {
|
||||
ArrayList<String> allProdukte = new ArrayList<>();
|
||||
for (Produkt p : produkte)
|
||||
allProdukte.add(anzahlProdkute + ".Produkt: " + p.print() + "\n");
|
||||
|
||||
return allProdukte;
|
||||
}
|
||||
|
||||
public int getAnzahlProdkute() {
|
||||
return anzahlProdkute;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
package de.hs_mannheim.informatik.rhenus.tui;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.util.Scanner;
|
||||
|
||||
import de.hs_mannheim.informatik.rhenus.domain.Kaufhalle;
|
||||
import de.hs_mannheim.informatik.rhenus.domain.ExceptionsKlassen.KundeNichtGefundenException;
|
||||
import de.hs_mannheim.informatik.rhenus.domain.ExceptionsKlassen.ProduktNichtGefundenException;
|
||||
|
||||
public class TUI {
|
||||
|
||||
private Kaufhalle kaufhalle;
|
||||
|
||||
public TUI() throws FileNotFoundException, ProduktNichtGefundenException, KundeNichtGefundenException {
|
||||
this.kaufhalle = new Kaufhalle();
|
||||
startProgramm();
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void startProgramm() throws FileNotFoundException, ProduktNichtGefundenException, KundeNichtGefundenException {
|
||||
Scanner eingabe = new Scanner(System.in);
|
||||
String produktname;
|
||||
String anschrift;
|
||||
System.out.println();
|
||||
System.out.println("<< Willkommen in meinem Online Shop >>");
|
||||
System.out.println();
|
||||
if (kaufhalle.produkteLaden()) {
|
||||
System.out.println("Meine aktuelle Produkte: ");
|
||||
for (String p : kaufhalle.zeigeProdukte())
|
||||
System.out.println(p);
|
||||
}
|
||||
|
||||
|
||||
System.out.print(">");
|
||||
produktname = eingabe.nextLine();
|
||||
kaufhalle.addProduktZuWarenkorb(produktname);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue