hello
commit
22155f7023
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
|
@ -0,0 +1 @@
|
|||
/bin/
|
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>2Semester</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
|
@ -0,0 +1,2 @@
|
|||
eclipse.preferences.version=1
|
||||
encoding/<project>=UTF-8
|
|
@ -0,0 +1,14 @@
|
|||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=17
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=17
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
|
||||
org.eclipse.jdt.core.compiler.release=enabled
|
||||
org.eclipse.jdt.core.compiler.source=17
|
|
@ -0,0 +1 @@
|
|||
Erste Zeichenkette
|
|
@ -0,0 +1 @@
|
|||
Firmenname "Apple"Firmenadresse "US"Bankverbindung "DE12345"
|
|
@ -0,0 +1 @@
|
|||
Firmenname "Google"Firmenadresse "US"Bankverbindung "US12456"
|
|
@ -0,0 +1 @@
|
|||
Firmenname "Google"Firmenadresse "US"Bankverbindung "US12345"
|
|
@ -0,0 +1 @@
|
|||
Firmenname = "HelloFresh"Firmenadresse = "Mannheim"Bankverbindung ="DE567788"
|
|
@ -0,0 +1 @@
|
|||
Firmenname = "dgfgfeg"Firmenadresse = "sfsfw"Bankverbindung ="eafedfw"
|
|
@ -0,0 +1,3 @@
|
|||
Firmenname = "fhhfd"
|
||||
Firmenadresse = "r4ffed"
|
||||
Bankverbindung ="4rfe224"
|
|
@ -0,0 +1,27 @@
|
|||
package fakturierungssystem;
|
||||
|
||||
public class Datenmodell {
|
||||
private String firmenname;
|
||||
private String firmenadresse;
|
||||
private String bankverbindung;
|
||||
|
||||
public String getFirmenname() {
|
||||
return firmenname;
|
||||
}
|
||||
public void setFirmenname(String firmenname) {
|
||||
this.firmenname = firmenname;
|
||||
}
|
||||
public String getFirmenadresse() {
|
||||
return firmenadresse;
|
||||
}
|
||||
public void setFirmenadresse(String firmenadresse) {
|
||||
this.firmenadresse = firmenadresse;
|
||||
}
|
||||
public String getBankverbindung() {
|
||||
return bankverbindung;
|
||||
}
|
||||
public void setBankverbindung(String bankverbindung) {
|
||||
this.bankverbindung = bankverbindung;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
Apple
|
||||
US
|
||||
DE1234
|
|
@ -0,0 +1,66 @@
|
|||
package fakturierungssystem;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.file.Files;
|
||||
import java.util.*;
|
||||
|
||||
public class MyFaktura {
|
||||
|
||||
private String firmenname;
|
||||
private String firmenadresse;
|
||||
private String bankverbindung;
|
||||
private static String cfgFile = "myconf6.txt";
|
||||
|
||||
public static void main(String[] args) {
|
||||
Scanner sc = new Scanner(System.in);
|
||||
File tempFile = new File(cfgFile);
|
||||
boolean exists = tempFile.exists();
|
||||
// falls Datei nicht vorhanden, anlegen
|
||||
if (exists == false) {
|
||||
try (BufferedWriter file = new BufferedWriter( new FileWriter(cfgFile))) {
|
||||
System.out.println("Firmenname:");
|
||||
String firma = sc.nextLine();
|
||||
char quote = '"';
|
||||
file.write("Firmenname = " + quote + firma + quote+"\n");
|
||||
System.out.println("Firmenadresse: ");
|
||||
String adresse = sc.nextLine();
|
||||
file.write("Firmenadresse = " + quote + adresse + quote+"\n");
|
||||
System.out.println("Bankverbindung: " );
|
||||
String bank = sc.nextLine();
|
||||
file.write("Bankverbindung =" + quote + bank + quote +"\n");
|
||||
file.close();
|
||||
System.out.println();
|
||||
} catch (IOException e) {
|
||||
|
||||
}
|
||||
} // falls Datei existiert
|
||||
else {
|
||||
try (BufferedReader file = new BufferedReader(new FileReader(cfgFile))) {
|
||||
System.out.println("Datei: ");
|
||||
String line;
|
||||
while((line=file.readLine())!= null) {
|
||||
System.out.println(line);
|
||||
}
|
||||
int c;
|
||||
String keyword="";
|
||||
String content ="";
|
||||
|
||||
/*while((c=file.read())!='=') {
|
||||
keyword+=(char)c;
|
||||
}
|
||||
while ((c =file.read())=='"') {
|
||||
content+=(char)c;
|
||||
}
|
||||
while ((c=file.read())!='"') {
|
||||
content+=(char)c;
|
||||
}
|
||||
System.out.println(keyword + "=" + content);
|
||||
*/ file.close();
|
||||
} catch (IOException e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
package fakturierungssystem;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
|
||||
public class Persistierung {
|
||||
private static String cfgFile;
|
||||
File tempFile = new File(cfgFile);
|
||||
boolean exists = tempFile.exists();
|
||||
BufferedWriter file;
|
||||
|
||||
{
|
||||
if (exists == false) {
|
||||
try (BufferedWriter file = new BufferedWriter(new FileWriter(cfgFile))) {
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void write(String satz) {
|
||||
try {
|
||||
file.write(satz);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
public void close() {
|
||||
try {
|
||||
file.close();
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package fakturierungssystem;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class UI {
|
||||
public static void main(String[] args) {
|
||||
|
||||
Scanner sc = new Scanner(System.in);
|
||||
Persistierung ps = new Persistierung();
|
||||
System.out.println("Firmenname:");
|
||||
String firma = sc.nextLine();
|
||||
char quote = '"';
|
||||
ps.write("Firmenname = " + quote + firma + quote + "\n");
|
||||
System.out.println("Firmenadresse: ");
|
||||
String adresse = sc.nextLine();
|
||||
ps.write("Firmenadresse = " + quote + adresse + quote + "\n");
|
||||
System.out.println("Bankverbindung: ");
|
||||
String bank = sc.nextLine();
|
||||
ps.write("Bankverbindung =" + quote + bank + quote + "\n");
|
||||
ps.close();
|
||||
System.out.println("Datei erfolgreich gespeichert");
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
package indexverwaltung;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
public class Datei {
|
||||
private int aktuell;
|
||||
private String dateiname;
|
||||
private int SATZLAENGE;
|
||||
private RandomAccessFile eineStammdatei;
|
||||
|
||||
|
||||
public void speichereSatz(String satz, int index) {
|
||||
|
||||
}
|
||||
|
||||
public String leseSatz(int index) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void öffneDatei(String name) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void schliesseDatei() {
|
||||
|
||||
}
|
||||
public int gibAnzahlDatensätze() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
private void positioniereAufSatz(int index) {
|
||||
|
||||
}
|
||||
|
||||
private String readFixedString (int länge) {
|
||||
return null;
|
||||
}
|
||||
|
||||
private void writeFixedString (String einDatensatz, int länge) {
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,96 @@
|
|||
package indexverwaltung;
|
||||
|
||||
import java.util.*;
|
||||
import java.io.*;
|
||||
|
||||
public class Index {
|
||||
// Attribute
|
||||
private final int MAX = 10;
|
||||
private String dateiname = "Indexdatei.txt";
|
||||
private int indextabelle[]; // 0 .. MAX-1
|
||||
private RandomAccessFile eineIndexDatei;
|
||||
|
||||
// Konstruktor
|
||||
public Index()
|
||||
{
|
||||
indextabelle = new int[MAX];
|
||||
// Initialisierung der indextabelle
|
||||
for(int i = 0; i < MAX; i++) indextabelle[i] = -1;
|
||||
// Kein Datensatz zu Schluessel vorhanden
|
||||
}
|
||||
|
||||
// Methoden
|
||||
public void erzeugeEintrag(int schluessel, int index) throws IOException
|
||||
{
|
||||
/** Speichert zu einen Schluessel den zugehoerigen
|
||||
* Datensatz-Index in der indextabelle
|
||||
*/
|
||||
if(schluessel < MAX)
|
||||
indextabelle[schluessel] = index;
|
||||
// Aktualisieren der Indexdatei,
|
||||
// d. h. Abspeichern der Datei
|
||||
aktualisiereIndexDatei(schluessel);
|
||||
}
|
||||
|
||||
public int gibIndexZuSchluessel(int schluessel)
|
||||
{
|
||||
// Gibt zu dem Schluessel den gefundenen
|
||||
// Datensatz-Index zurueck
|
||||
if(schluessel < MAX)
|
||||
return indextabelle[schluessel];
|
||||
// oder -1, wenn Schluessel zu gross ist
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
public void ladeIndexDatei() throws IOException
|
||||
{
|
||||
/** Liest die Indextabelle vollstaendig aus einer Datei
|
||||
* Dies geschieht nur beim Start des Programms
|
||||
*/
|
||||
eineIndexDatei = new RandomAccessFile(dateiname, "r");
|
||||
int index;
|
||||
for(int schluessel = 0; schluessel < MAX; schluessel++)
|
||||
{
|
||||
index = eineIndexDatei.readInt();
|
||||
indextabelle[schluessel] = index;
|
||||
}
|
||||
eineIndexDatei.close();
|
||||
}
|
||||
|
||||
public void speichereIndexDatei() throws IOException
|
||||
{
|
||||
/** Speichert die Indextabelle vollstaendig in einer Datei
|
||||
* Dies geschlieht beim beenden des Programs
|
||||
*/
|
||||
eineIndexDatei = new RandomAccessFile(dateiname, "rw");
|
||||
for(int schluessel = 0; schluessel < MAX; schluessel++)
|
||||
eineIndexDatei.writeInt(indextabelle[schluessel]);
|
||||
eineIndexDatei.close();
|
||||
}
|
||||
|
||||
private void aktualisiereIndexDatei(int schluessel) throws IOException
|
||||
{
|
||||
/** Aktualisiert die indextabelle in der Indexdatei
|
||||
* Dies geschliet beim Hinzufuegen eines neuen
|
||||
* Indexes oder Aendern eines alten Indexes
|
||||
*/
|
||||
eineIndexDatei = new RandomAccessFile(dateiname, "rw");
|
||||
// eine int-Zahl belegt 4 Bytes
|
||||
eineIndexDatei.seek((long)(schluessel * 4));
|
||||
eineIndexDatei.writeInt(indextabelle[schluessel]);
|
||||
eineIndexDatei.close();
|
||||
}
|
||||
|
||||
// Zum Testen
|
||||
public void gibIndextabelleAus()
|
||||
{
|
||||
int schluessel = 0;
|
||||
for(int element : indextabelle)
|
||||
{
|
||||
System.out.println(schluessel + " " + element);
|
||||
schluessel++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
package indexverwaltung;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
public class IndexUI {
|
||||
Scanner sc = new Scanner(System.in);
|
||||
static File tempFile = new File("Datei.txt");
|
||||
static boolean exists = tempFile.exists();
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println("Willkommen! ");
|
||||
//wenn keine Datei existiert
|
||||
|
||||
if (exists == false) {
|
||||
try (BufferedWriter file = new BufferedWriter(new FileWriter("Datei.txt"))) {
|
||||
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package verwaltung.kunden;
|
||||
|
||||
public class Adresse {
|
||||
|
||||
String Strasse;
|
||||
int hausnummer;
|
||||
int postleitzahl;
|
||||
String ort;
|
||||
|
||||
public Adresse(String str, int h, int p,String o) {
|
||||
this.Strasse=str;
|
||||
this.hausnummer=h;
|
||||
this.postleitzahl=p;
|
||||
this.ort=o;
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package verwaltung.kunden;
|
||||
|
||||
public class Auftrag {
|
||||
int auftragsnummer = 0;
|
||||
|
||||
public Auftrag() {
|
||||
auftragsnummer++;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package verwaltung.kunden;
|
||||
|
||||
public class Geschäftsauftrag extends Auftrag {
|
||||
private int gaauftragsnummer=0;
|
||||
private String produkt;
|
||||
|
||||
public Geschäftsauftrag(String p) {
|
||||
gaauftragsnummer++;
|
||||
this.produkt=p;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package verwaltung.kunden;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class Geschäftskunde extends Kunde {
|
||||
String firmenname;
|
||||
ArrayList<Geschäftsauftrag> auftragsListe;
|
||||
|
||||
public Geschäftskunde(int kundennummer2,String firmenname, int iBAN2, ArrayList<Adresse> adresse, ArrayList<Auftrag> aListe) {
|
||||
super(kundennummer2, iBAN2, adresse);
|
||||
this.firmenname=firmenname;
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
public void neuerAuftrag(String p) {
|
||||
Geschäftsauftrag auftrag = new Geschäftsauftrag(p);
|
||||
auftragsListe.add(auftrag);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
package verwaltung.kunden;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class Kunde {
|
||||
private int kundennummer;// unerlaubten Zugriff vermeiden
|
||||
private int IBAN;// unerlaubten Zugriff vermeiden
|
||||
protected ArrayList<Adresse> adressListe;
|
||||
|
||||
public Kunde(int kundennummer2, int iBAN2, ArrayList<Adresse> adresse) {
|
||||
this.setKundennummer(kundennummer);
|
||||
this.setIBAN(IBAN);
|
||||
this.adressListe = adresse;
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
public boolean neuerAdresse(Adresse eineAdresse) {
|
||||
return adressListe.add(eineAdresse);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @Override clone();
|
||||
*/
|
||||
public Kunde clone() {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* public Kunde copy() {
|
||||
*
|
||||
*
|
||||
* return this; }
|
||||
*/
|
||||
|
||||
public int getKundennummer() {// jeder soll auf die Kundennummer zugreifen können, nicht verändern
|
||||
return kundennummer;
|
||||
}
|
||||
|
||||
public void setKundennummer(int kundennummer) {// soll möglichst unveränderbar sein
|
||||
this.kundennummer = kundennummer;
|
||||
}
|
||||
|
||||
/** Multiplizitäten 1:n */
|
||||
|
||||
public int getIBAN() {
|
||||
return IBAN;
|
||||
}
|
||||
|
||||
public void setIBAN(int iBAN) {
|
||||
IBAN = iBAN;
|
||||
}
|
||||
|
||||
public static void main(String args[]) {
|
||||
Adresse adresse1 = new Adresse("Mainauer", 3, 76523, "Mannheim");
|
||||
ArrayList<Adresse> Mannheim = new ArrayList<Adresse>();
|
||||
Kunde kunde1 = new Kunde(12345, 785578, Mannheim);
|
||||
Kunde kunde2 = null;
|
||||
kunde2 = kunde1.clone();
|
||||
// kunde2=kunde1.copy();
|
||||
System.out.println(kunde1);
|
||||
System.out.println(kunde2);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package verwaltung.kunden;
|
||||
|
||||
public class Privatauftrag extends Auftrag{
|
||||
private int paauftragsnummer=0;
|
||||
private String produkt;
|
||||
|
||||
public Privatauftrag(String p) {
|
||||
paauftragsnummer++;
|
||||
this.produkt=p;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package verwaltung.kunden;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class Privatkunde extends Kunde{
|
||||
private String name;
|
||||
ArrayList<Privatauftrag> auftragsListe;
|
||||
|
||||
public Privatkunde(int kundennummer, int IBAN,String name,ArrayList<Adresse> adresse, ArrayList<Auftrag> aListe) {//beim Erstellen des Objektes soll immer zugreifbar sein
|
||||
super(kundennummer, IBAN, adresse);
|
||||
this.setName(name);
|
||||
}
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
private void setName(String name) {//soll möglichst unveränderbar sein
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public void neuerAuftrag(String p) {
|
||||
Privatauftrag auftrag = new Privatauftrag(p);
|
||||
auftragsListe.add(auftrag);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue