public interface Service {}
public class AuthorizationService implements Service {}
public class UserMenuService implements Service {}
public class AdminMenuService implements Service {}
public class ServiceFactory {
public static final int AUTHORIZATION = 1;
public static final int USERMENU = 2;
public static final int ADMINMENU = 3;
public static Service create(int id) throws Exception {
switch (id) {
case AUTHORIZATION: return new AuthorizationService();
case USERMENU: return new UserMenuService();
case ADMINMENU: return new AdminMenuService();
default: throw new Exception("service factory wrong id:" + id);
}
}
}
#include <iostream>
#include <windows.h>
using namespace std;
int main()
{
int val =0, timer = 0, freq = 50;
while(true) {
Sleep(1000/freq); //win-функция
timer += 1000/freq;
if (timer > 1000) {
timer -= 1000;
cout << val++ << endl;
}
if (GetAsyncKeyState(VK_SPACE)) { //win-функция
cout << "New val: ";
cin >> val;
}
}
system("pause");
return 0;
}