mirror of
https://inf.pirckheimer-gymnasium.de/kebab/kebab
synced 2026-08-26 16:31:23 +00:00
Implement ConfigGroup for Statistics
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
package project;
|
package project;
|
||||||
|
|
||||||
import project.scenes.LoadingScene;
|
import project.scenes.LoadingScene;
|
||||||
|
import project.utils.Statistics;
|
||||||
import pi.Controller;
|
import pi.Controller;
|
||||||
|
|
||||||
import java.awt.Cursor;
|
import java.awt.Cursor;
|
||||||
@@ -24,5 +25,8 @@ public class Main
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Controller.config.add(new Statistics());
|
||||||
|
Controller.config.getGroup(Statistics.class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,100 +0,0 @@
|
|||||||
package project.utils;
|
|
||||||
|
|
||||||
public class Ordersystem {
|
|
||||||
private int money = 0;
|
|
||||||
private int kebabPrice = 5;
|
|
||||||
private int upgradeLevel = 0;
|
|
||||||
private int kebabSold = 0;
|
|
||||||
private int workers = 0;
|
|
||||||
private int waitingCustomers = 0;
|
|
||||||
private int totalEarned = 0;
|
|
||||||
|
|
||||||
public int getMoney(){
|
|
||||||
return money;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getKebabSold(){
|
|
||||||
return kebabSold;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setKebabPrice(int price){
|
|
||||||
kebabPrice = price;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean buyUpgrade() {
|
|
||||||
int cost = (upgradeLevel + 1) * 50;
|
|
||||||
|
|
||||||
if(money >= cost) {
|
|
||||||
money -= cost;
|
|
||||||
upgradeLevel++;
|
|
||||||
kebabPrice += 2;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getUpgradeLevel() {
|
|
||||||
return upgradeLevel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean buyWorker() {
|
|
||||||
int cost = getWorkerCost();
|
|
||||||
|
|
||||||
if(money >= cost) {
|
|
||||||
money -= cost;
|
|
||||||
workers++;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getWorkers() {
|
|
||||||
return workers;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addCustomer() {
|
|
||||||
waitingCustomers++;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean sellKebab() {
|
|
||||||
if(waitingCustomers > 0) {
|
|
||||||
waitingCustomers--;
|
|
||||||
money += kebabPrice;
|
|
||||||
totalEarned += kebabPrice;
|
|
||||||
kebabSold++;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getTotalIncome() {
|
|
||||||
return totalEarned;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getWaitingCustomers() {
|
|
||||||
return waitingCustomers;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getKebabPrice() {
|
|
||||||
return kebabPrice;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getUpgradeCost() {
|
|
||||||
return (upgradeLevel + 1) * 50;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getWorkerCost() {
|
|
||||||
return 100 + workers * 50;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void workerSellKebabs() {
|
|
||||||
for(int i = 0; i < workers; i++) {
|
|
||||||
if (waitingCustomers > 0) {
|
|
||||||
sellKebab();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,92 @@
|
|||||||
|
package project.utils;
|
||||||
|
|
||||||
|
import pi.config.ConfigGroup;
|
||||||
|
|
||||||
|
public class Statistics extends ConfigGroup {
|
||||||
|
private int money;
|
||||||
|
private int kebabPrice = 5;
|
||||||
|
private int upgradeLevel = 0;
|
||||||
|
private int kebabSold = 0;
|
||||||
|
private int workers = 0;
|
||||||
|
private int waitingCustomers = 0;
|
||||||
|
private int totalEarned = 0;
|
||||||
|
|
||||||
|
public Statistics() {
|
||||||
|
money(0);
|
||||||
|
kebabPrice(5);
|
||||||
|
upgradeLevel(0);
|
||||||
|
kebabSold(0);
|
||||||
|
workers(0);
|
||||||
|
waitingCustomers(0);
|
||||||
|
totalEarned(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- money ---
|
||||||
|
public int money(){
|
||||||
|
return money;
|
||||||
|
}
|
||||||
|
public Statistics money(int money) {
|
||||||
|
set("money", money);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- kebabPrice ---
|
||||||
|
public int kebabPrice() {
|
||||||
|
return kebabPrice;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Statistics kebabPrice(int kebabPrice) {
|
||||||
|
set("kebabPrice", kebabPrice);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- upgradeLevel ---
|
||||||
|
public int upgradeLevel() {
|
||||||
|
return upgradeLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Statistics upgradeLevel(int upgradeLevel) {
|
||||||
|
set("upgradeLevel", upgradeLevel);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- kebabSold ---
|
||||||
|
public int kebabSold() {
|
||||||
|
return kebabSold;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Statistics kebabSold(int kebabSold) {
|
||||||
|
set("kebabSold", kebabSold);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- workers ---
|
||||||
|
public int workers() {
|
||||||
|
return workers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Statistics workers(int workers) {
|
||||||
|
set("workers", workers);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- waitingCustomers ---
|
||||||
|
public int waitingCustomers() {
|
||||||
|
return waitingCustomers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Statistics waitingCustomers(int waitingCustomers) {
|
||||||
|
set("waitingCustomers", waitingCustomers);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- totalEarned ---
|
||||||
|
public int totalEarned() {
|
||||||
|
return totalEarned;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Statistics totalEarned(int totalEarned) {
|
||||||
|
set("totalEarned", totalEarned);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user