Skip to content
Snippets Groups Projects
Commit f8fc451c authored by s90532's avatar s90532
Browse files

tests

parent 49bb2d72
No related branches found
No related tags found
No related merge requests found
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/ramenautomat.iml" filepath="$PROJECT_DIR$/.idea/ramenautomat.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<module type="CPP_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
<mapping directory="$PROJECT_DIR$/tests/unittest_paymentprocessor" vcs="Git" />
</component>
</project>
\ No newline at end of file
......@@ -13,7 +13,7 @@ void Ausgabefach::oeffne_Tuer() {
void Ausgabefach::nimm_Sosse() {
if (tuer_offen_) {
std::cout << "Soße wird genommen." << std::endl;
// Hier kannst du den Code hinzufügen, um die Soße zu nehmen
} else {
std::cout << "Die Tür ist geschlossen. Soße kann nicht genommen werden." << std::endl;
}
......
#include "elektro.h"
elektro::elektro() {}
#ifndef ELEKTRO_H
#define ELEKTRO_H
class elektro
{
public:
elektro();
};
#endif // ELEKTRO_H
......@@ -23,3 +23,10 @@ int Elektromotor::getPosition() const {
return position;
}
void Elektromotor::setGeschwindigkeit(int geschw) {
geschwindigkeit = geschw;
}
int Elektromotor::getGeschwindigkeit() const {
return geschwindigkeit;
}
......@@ -12,6 +12,8 @@ public:
void stop();
void bewegezurPosition(int neu);
int getPosition() const;
void setGeschwindigkeit(int geschw);
int getGeschwindigkeit() const;
private:
int geschwindigkeit;
......
#include "fahrstuhl.h"
#include <iostream>
Fahrstuhl::Fahrstuhl(): aktuelleEtage(0), zielEtage(0), elektromotor()
Fahrstuhl::Fahrstuhl(): aktuelleEtage(0), zielEtage(0)
{
}
void Fahrstuhl::hoch() {}
void Fahrstuhl::hoch() {
elektromotor.antreiben();
aktuelleEtage++;
elektromotor.bewegezurPosition(aktuelleEtage);
elektromotor.stop();
}
void Fahrstuhl::links() {}
void Fahrstuhl::runter() {
elektromotor.antreiben();
aktuelleEtage--;
elektromotor.bewegezurPosition(aktuelleEtage);
elektromotor.stop();
}
void Fahrstuhl::rechts() {}
void Fahrstuhl::rechts() {
elektromotor.antreiben();
std::cout << "Der Fahrstuhl bewegt sich nach rechts." << std::endl;
elektromotor.stop();
}
void Fahrstuhl::runter() {}
void Fahrstuhl::links() {
elektromotor.antreiben();
std::cout << "Der Fahrstuhl bewegt sich nach links." << std::endl;
elektromotor.stop();
}
void Fahrstuhl::bewegeFahrstuhl() {
if (gewichtssensor.istRamenSchuesselErkannt()) {
std::cout << "Gewicht erkannt. Der Fahrstuhl bewegt sich von Etage " << aktuelleEtage << " zu Etage " << zielEtage << "." << std::endl;
// elektromotor.antreiben();
//elektromotor.bewegezurPosition(zielEtage);
aktuelleEtage = zielEtage;
//elektromotor.stop();
stoppeAnLichtsensoren();
} else {
std::cout << "Kein ausreichendes Gewicht erkannt. Der Fahrstuhl bleibt auf Etage " << aktuelleEtage << "." << std::endl;
......@@ -26,7 +47,6 @@ void Fahrstuhl::bewegeFahrstuhl() {
void Fahrstuhl::setzeZielEtage(int etage) {
zielEtage = etage;
elektromotor.antreiben();
}
void Fahrstuhl::fuegeLichtsensorHinzu(Lichtsensor* sensor) {
......@@ -37,6 +57,7 @@ void Fahrstuhl::stoppeAnLichtsensoren() {
for (Lichtsensor* sensor : lichtsensoren) {
if (sensor->istLichtErkannt()) {
std::cout << "Lichtsensor erkannt. Der Fahrstuhl stoppt an Etage " << aktuelleEtage << "." << std::endl;
elektromotor.stop();
}
}
}
......@@ -48,13 +69,14 @@ int Fahrstuhl::getAktuelleEtage() const {
int Fahrstuhl::getZielEtage() const {
return zielEtage;
}
/*
void Fahrstuhl::fahreZuEtage(int etage) {
std::cout << "Fahrstuhl fährt zur Etage " << etage << std::endl;
elektromotor.bewegezurPosition(etage);
elektromotor.antreiben();
}
*/
void Fahrstuhl::stop() {
elektromotor.stop();
}
......@@ -62,4 +84,4 @@ void Fahrstuhl::stop() {
int Fahrstuhl::getAktuellePosition() const {
return elektromotor.getPosition();
}
*/
......@@ -4,6 +4,7 @@
#include "lichtsensor.h"
#include <vector>
#include "elektromotor.h"
#include "elektro.h"
class Fahrstuhl
{
......@@ -20,8 +21,8 @@ public:
int getAktuelleEtage() const;
int getZielEtage() const;
//void fahreZuEtage(int etage);
void stop();
int getAktuellePosition() const;
// void stop();
//int getAktuellePosition() const;
private:
int aktuelleEtage;
......@@ -29,6 +30,7 @@ private:
Gewichtssensor gewichtssensor;
Elektromotor elektromotor;
std::vector<Lichtsensor*> lichtsensoren;
//elektro elektro_;
};
......@@ -21,6 +21,7 @@ SOURCES += \
bezahlen.cpp \
dialog1.cpp \
display.cpp \
elektro.cpp \
elektromagnetischer_sensor.cpp \
elektromotor.cpp \
fahrstuhl.cpp \
......@@ -38,9 +39,11 @@ SOURCES += \
mainwindow.cpp \
mitarbeiter.cpp \
motor.cpp \
motorcontroller.cpp \
muenzentyp.cpp \
paymentprocessor.cpp \
preis.cpp \
preisberechnung.cpp \
produkt.cpp \
ramenabteilung.cpp \
ramenart.cpp \
......@@ -65,6 +68,7 @@ HEADERS += \
bezahlen.h \
dialog1.h \
display.h \
elektro.h \
elektromagnetischer_sensor.h \
elektromotor.h \
fahrstuhl.h \
......@@ -80,9 +84,11 @@ HEADERS += \
mainwindow.h \
mitarbeiter.h \
motor.h \
motorcontroller.h \
muenzentyp.h \
paymentprocessor.h \
preis.h \
preisberechnung.h \
produkt.h \
ramenabteilung.h \
ramenart.h \
......
......@@ -9,13 +9,25 @@ int Lichtsensor::erkenneIntensitaet() const {
}
int Lichtsensor::erkenneGroesseDerMuenze() const {
// Implementierung zur Erkennung der Münzgröße
return 0;
int lichtwert = erkenneIntensitaet();
if (lichtwert < 20) {
return 1; // Kleine Münze erkannt
} else if (lichtwert < 50) {
return 2; // Mittlere Münze erkannt
} else {
return 3; // Große Münze erkannt
}
}
int Lichtsensor::erkenneScheintyp() const {
// Implementierung zur Erkennung des Scheintyps
return 0;
int lichtwert = erkenneIntensitaet();
if (lichtwert < 20) {
return 1; // Schein Typ 1 erkannt
} else if (lichtwert < 50) {
return 2; // Schein Typ 2 erkannt
} else {
return 3;
}
}
bool Lichtsensor::istAktiviert() const {
......
......@@ -13,8 +13,12 @@ public:
void setzeAktivierung(bool status); // Methode zum Aktivieren/Deaktivieren des Sensors
bool istLichtErkannt() const; // Methode zum Überprüfen, ob Licht erkannt wurde
private:
bool aktiviert;
};
#endif // LICHTSENSOR_H
#include "mainwindow.h"
#include <QApplication>
#include <iostream>
#include "paymentprocessor.h"
#include "zubereitung.h"
#include "preisberechnung.h"
int main(int argc, char *argv[])
{
using namespace std;
QApplication a(argc, argv);
MainWindow w;
w.show();
Zubereitung zubereitung(Tonkotsu, Soy);
zubereitung.ramenzubereiten();
cout << "Preis: " << zubereitung.getprice() << " Euro" << endl;
PaymentProcessor processor(&zubereitung);
return a.exec();
}
......@@ -18,6 +18,7 @@ MainWindow::MainWindow(QWidget *parent) :
selectedSauce(Soy)
{
ui->setupUi(this);
//secondwindow->show();
Zubereitung *zubereitung = new Zubereitung(selectedRamen, selectedSauce);
......@@ -75,6 +76,7 @@ MainWindow::MainWindow(QWidget *parent) :
updateLabels(); connect(ui->buttonCheckCashBalance, &QPushButton::clicked, this, &MainWindow::checkCashBalance);
connect(ui->buttonClearCashBalance, &QPushButton::clicked, this, &MainWindow::clearCashBalance);
connect(ui->startSimulationButton, &QPushButton::clicked, this, &MainWindow::on_startSimulationButton_clicked);
connect(paymentProcessor, &PaymentProcessor::paymentSuccessful, this, &MainWindow::updateChangeLabel);
/*
QPixmap ramen(":/re.png");
......@@ -314,8 +316,10 @@ void MainWindow::updatePaidAmount(double amount)
void MainWindow::showPaymentSuccessMessage()
{
double change = paymentProcessor->getChange();
QString message = QString("Vielen Dank für Ihre Zahlung! Rückgeld: %1 €").arg(change);
QMessageBox::information(this, "Bezahlung erfolgreich", "Vielen Dank für Ihre Zahlung!");
paymentProcessor->reset();
//paymentProcessor->reset();
updatePaidAmount(paymentProcessor->getPaidAmount());
}
......@@ -526,3 +530,11 @@ void MainWindow::on_startSimulationButton_clicked()
secondwindow->startSimulation();
secondwindow->show();
}
void MainWindow::updateChangeLabel()
{
double change = paymentProcessor->getChange();
ui->changeLabel->setText(QString("Rückgeld: %1 €").arg(change));
paymentProcessor->reset();
}
......@@ -65,6 +65,7 @@ private slots:
void on_pushButton_4_clicked();
void updateChangeLabel();
private:
Ui::MainWindow *ui;
......
......@@ -1478,6 +1478,19 @@ li.checked::marker { content: &quot;\2612&quot;; }
<string>PushButton</string>
</property>
</widget>
<widget class="QLabel" name="changeLabel">
<property name="geometry">
<rect>
<x>60</x>
<y>430</y>
<width>161</width>
<height>41</height>
</rect>
</property>
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</widget>
</widget>
</item>
......
#include "MotorController.h"
#include <iostream>
MotorController::MotorController(Elektromotor& motor) : motor(motor) {}
void MotorController::fahreZuPosition(int position) {
std::cout << "Bewege Motor zu Position " << position << std::endl;
motor.bewegezurPosition(position);
}
void MotorController::starteMotorMitGeschwindigkeit(int geschwindigkeit) {
std::cout << "Starte Motor mit Geschwindigkeit " << geschwindigkeit << std::endl;
motor.setGeschwindigkeit(geschwindigkeit);
motor.antreiben();
}
void MotorController::stoppeMotor() {
std::cout << "Stoppe Motor" << std::endl;
motor.stop();
}
void MotorController::statusAnzeige() {
std::cout << "Aktuelle Position: " << motor.getPosition() << std::endl;
std::cout << "Aktuelle Geschwindigkeit: " << motor.getGeschwindigkeit() << std::endl;
}
#ifndef MOTORCONTROLLER_H
#define MOTORCONTROLLER_H
#include "elektromotor.h"
class MotorController
{
public:
MotorController(Elektromotor& motor);
void fahreZuPosition(int position);
void starteMotorMitGeschwindigkeit(int geschwindigkeit);
void stoppeMotor();
void statusAnzeige();
private:
Elektromotor& motor;
};
#endif // MOTORCONTROLLER_H
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment