Skip to content
Snippets Groups Projects
Commit 2f01f791 authored by Kai Renz's avatar Kai Renz
Browse files

Classroom Project initial commit

parents
No related branches found
No related tags found
No related merge requests found
cmake_minimum_required(VERSION 3.16)
project(OOAD_Refactoring_Demo)
set(CMAKE_CXX_STANDARD 14)
add_executable(OOAD_Refactoring_Demo main.cpp)
/* Define classes and dummy methods (only for refactoring demo */
class Rezept {
public:
int dummy=0;
string getRezeptName(){return "Hallo"; };
int getAnzahlRezeptZutaten() {return 5;};
string getZutat(int j){ return "Zutat";};
};
class VorhandeneZutaten{
public:
int dummy=0;
int getAnzahlZutaten() {return 5;};
string getVorhandeneZutat(int j){ return "Zutat";};
};
Rezept* getRezept(int i){
Rezept* r= new Rezept;
return r;
}
int getAnzahlRezepte(){
return 42;
}
\ No newline at end of file
# Implementing for Maintainability - Demo for Refactoring
This project is about refactoring an ugly method of the famous CocktailPro. The CocktailPro is a software controlled machine that mixes cocktails (e.g. the Caipirinha). It uses recipes of cocktails and available ingredients to find out what cocktails can be mixed. This is done by the method *pruefeRezepte()* which is quite a mess.
You are supposed to clean up the method by using refactorings.
Enjoy
Ralf Hahn
#include <iostream>
#include <string>
using namespace std;
/* Include Dummy Code to make demo compile */
/* Ignore for refactoring demo! */
#include "DummyCode.cpp"
/* End of code to be ignored */
void pruefeRezepte(VorhandeneZutaten VZ){
int i, j, k;
bool da;
for (i=0; i<getAnzahlRezepte(); i++){
Rezept* r = getRezept(i);
cout << i << ". " << r->getRezeptName() << ": ";
da=true;
for (j = 0; j < r->getAnzahlRezeptZutaten(); j++) {
string z = r->getZutat(j);
bool OK= false;
for (k=0; k<VZ.getAnzahlZutaten();k++){
if (z==VZ.getVorhandeneZutat(k)){
OK= true;
break;
}
}
if (OK== false) {
da = false;
break;
}
}
if (da == true) {
cout << " mischbar\n"; }
else { cout << " nicht mischbar!\n"; }
}
}
\ No newline at end of file
#include <iostream>
#include "RefactoringDemo.cpp"
int main() {
std::cout << "This is the Refactoring Demo!" << std::endl;
return 0;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment