An application developed as part of my computer architecture class to model a 16-bit CPU down to its registers and the way it processes instructions and data.
❖ Model View Presenter (MVP)
❖ Delegation
Model → Defines the data to be displayed.
View → Displays the data and routes events to the presenter.
Presenter → Acts upon the model and the view.
Using Java 8’s lambda expressions:
interface StringFunc {
String func(String s);
}
void doSomething(StringFunc funk) {
System.out.println(funk.func("whatever"));
}
doSomething((t) -> t + "asd");
doSomething((t) -> new StringBuilder(t).reverse().toString());
Using function pointers in c++:
int doubleIt(int d) {
return d * 2;
}
int halveIt(int d) {
return d / 2;
}
typedef int (*MyFuncT) (int d);
MyFuncT fp = &doubleIt;
cout << fp(3);
fp = &halveIt;
cout << fp(3);
Note: This program was created using Qt Creator so you will either need to install it and import the project file or setup your build system's dependecies accordingly