Updated Main to be English and use the ORM class
Signed-off-by: Jim Martens <github@2martens.de>
This commit is contained in:
@ -1,38 +1,39 @@
|
|||||||
package de.dis2017;
|
package de.dis2017;
|
||||||
|
|
||||||
import de.dis2017.data.Makler;
|
import de.dis2017.data.EstateAgent;
|
||||||
|
import de.dis2017.data.db.ORM;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hauptklasse
|
* Main class
|
||||||
*/
|
*/
|
||||||
public class Main {
|
public class Main {
|
||||||
/**
|
/**
|
||||||
* Startet die Anwendung
|
* Starts the application.
|
||||||
*/
|
*/
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
showMainMenu();
|
showMainMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Zeigt das Hauptmenü
|
* Shows the main menu.
|
||||||
*/
|
*/
|
||||||
public static void showMainMenu() {
|
private static void showMainMenu() {
|
||||||
//Menüoptionen
|
// menu options
|
||||||
final int MENU_MAKLER = 0;
|
final int MENU_AGENT = 0;
|
||||||
final int QUIT = 1;
|
final int QUIT = 1;
|
||||||
|
|
||||||
//Erzeuge Menü
|
// create menu
|
||||||
Menu mainMenu = new Menu("Hauptmenü");
|
Menu mainMenu = new Menu("Main menu");
|
||||||
mainMenu.addEntry("Makler-Verwaltung", MENU_MAKLER);
|
mainMenu.addEntry("EstateAgent management", MENU_AGENT);
|
||||||
mainMenu.addEntry("Beenden", QUIT);
|
mainMenu.addEntry("Quit", QUIT);
|
||||||
|
|
||||||
//Verarbeite Eingabe
|
// process input
|
||||||
while(true) {
|
while(true) {
|
||||||
int response = mainMenu.show();
|
int response = mainMenu.show();
|
||||||
|
|
||||||
switch(response) {
|
switch(response) {
|
||||||
case MENU_MAKLER:
|
case MENU_AGENT:
|
||||||
showMaklerMenu();
|
showEstateAgentMenu();
|
||||||
break;
|
break;
|
||||||
case QUIT:
|
case QUIT:
|
||||||
return;
|
return;
|
||||||
@ -41,25 +42,25 @@ public class Main {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Zeigt die Maklerverwaltung
|
* Shows the estate management.
|
||||||
*/
|
*/
|
||||||
public static void showMaklerMenu() {
|
private static void showEstateAgentMenu() {
|
||||||
//Menüoptionen
|
// menu options
|
||||||
final int NEW_MAKLER = 0;
|
final int NEW_AGENT = 0;
|
||||||
final int BACK = 1;
|
final int BACK = 1;
|
||||||
|
|
||||||
//Maklerverwaltungsmenü
|
// estate management menu
|
||||||
Menu maklerMenu = new Menu("Makler-Verwaltung");
|
Menu estateAgentMenu = new Menu("EstateAgent management");
|
||||||
maklerMenu.addEntry("Neuer Makler", NEW_MAKLER);
|
estateAgentMenu.addEntry("Create EstateAgent", NEW_AGENT);
|
||||||
maklerMenu.addEntry("Zurück zum Hauptmenü", BACK);
|
estateAgentMenu.addEntry("Back to the main menu", BACK);
|
||||||
|
|
||||||
//Verarbeite Eingabe
|
// process input
|
||||||
while(true) {
|
while(true) {
|
||||||
int response = maklerMenu.show();
|
int response = estateAgentMenu.show();
|
||||||
|
|
||||||
switch(response) {
|
switch(response) {
|
||||||
case NEW_MAKLER:
|
case NEW_AGENT:
|
||||||
newMakler();
|
newEstateAgent();
|
||||||
break;
|
break;
|
||||||
case BACK:
|
case BACK:
|
||||||
return;
|
return;
|
||||||
@ -68,18 +69,19 @@ public class Main {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Legt einen neuen Makler an, nachdem der Benutzer
|
* Creates a new estate agent after the usesr has entered the necessary data.
|
||||||
* die entprechenden Daten eingegeben hat.
|
|
||||||
*/
|
*/
|
||||||
public static void newMakler() {
|
private static void newEstateAgent() {
|
||||||
Makler m = new Makler();
|
EstateAgent agent = new EstateAgent();
|
||||||
|
|
||||||
m.setName(FormUtil.readString("Name"));
|
agent.setName(FormUtil.readString("Name"));
|
||||||
m.setAddress(FormUtil.readString("Adresse"));
|
agent.setAddress(FormUtil.readString("Address"));
|
||||||
m.setLogin(FormUtil.readString("Login"));
|
agent.setLogin(FormUtil.readString("Login"));
|
||||||
m.setPassword(FormUtil.readString("Passwort"));
|
agent.setPassword(FormUtil.readString("Password"));
|
||||||
m.save();
|
|
||||||
|
|
||||||
System.out.println("Makler mit der ID "+m.getId()+" wurde erzeugt.");
|
ORM orm = new ORM();
|
||||||
|
orm.persist(agent);
|
||||||
|
|
||||||
|
System.out.println("EstateAgent with the ID " + agent.getId() + " was created.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user