- Home /
is there any different solution for different buildings different behaviours
class agricultural{
Workr Work
void Working(Work W){
Behaviour1();
}
}
class Carpentry{
Workr Work
void Working(Work W){
Behaviour2();
}
}
template <tipename T> class BuildWork{
T BW
Work(){
BW.Working();
}
}
something like that but problem occurs as when I would wont to declare template
class Workr{
// here I would need to make it only for 1
BuildWork <agricultural> BW
}
so this is no use or is it?
so next thing occured to me is this
class Building{
bool beh[2];
void Work(Workr W){
if beh[0]{
if (beh[1]){
behaviour0(Workr W);
}
else{
behaviour1(Workr W);
}
}
else{
if (beh[1]){
behaviour2(Workr W);
}
else{
behaviour3(Workr W);
}
}
}
}
the last code is workable but I wander if there is any better solution to be made thanks
PS. if code isn't logically made I'm sorry as I cam only use hospital's computer and I'm programming with pencil on a piece of papres
Comment
Do you want interface for void Working()
since every class has its own implementation ?
Your answer

Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Can't Encode MD5 2 Answers
How to inject dependancies written in C# into Unityscript? 1 Answer