11.03.2016, 01:00
Hello again
I made this post since I am really frustrated. I have been trying to do a design for create Jobs but simply I can't.
I have tried the following:
- Singleton class (Reason: I need only an instance for the main class: Jobs and I need to pass the EventManager object. After it I should be able to create and destroy Job objects, like TruckDriver)
- Static abstract class with subclasses (I need the same of above, trying to do it in another way)
- Static class (How to get the EventManager? with a method? when?)
- Normal class (Class I am trying to do)
And the only thing I have done is the following:
Here is the design I have planned
Jobs (Superclass)
KindOfJob(Thinking about it)
Pilot is a job so it'll need the "Job" variables and methods
Truck driver is a job so it'll need the "Job" variables and methods
Jobs class will be dependent of some classes, like ePlayer class to see if the player is using a checkpoint
And now my mind just exploded about the desing
I really appreciate any help about this or a link where I can learn about OOP desing, that to be honest, seems to be much more difficult than debugging a 100k lines non-OO program.
I made this post since I am really frustrated. I have been trying to do a design for create Jobs but simply I can't.
I have tried the following:
- Singleton class (Reason: I need only an instance for the main class: Jobs and I need to pass the EventManager object. After it I should be able to create and destroy Job objects, like TruckDriver)
- Static abstract class with subclasses (I need the same of above, trying to do it in another way)
- Static class (How to get the EventManager? with a method? when?)
- Normal class (Class I am trying to do)
And the only thing I have done is the following:
PHP код:
import net.gtaun.shoebill.common.command.Command;
import net.gtaun.shoebill.common.command.CommandHelp;
import net.gtaun.shoebill.common.command.PlayerCommandManager;
import net.gtaun.util.event.EventManager;
import net.gtaun.util.event.HandlerPriority;
/**
* Created by Erich on 05/03/2016.
*/
public class Jobs{
private EventManager events;
private PlayerCommandManager commandEvents;
public Jobs(EventManager events){
this.events= events;
commandEvents= new PlayerCommandManager(events);
commandEvents.installCommandHandler(HandlerPriority.NORMAL);
commandEvents.registerCommands(new JobCommands());
}
//I am now thinking about to add something like: enablePilotJob()
public class Pilot{
Pilot(){
//Do some stuff here
}
}
public class JobCommands{
@Command
public boolean job(){
return true;
}
public boolean leave(String option){
if(!option.contains("job")){
return true;
}
return true;
}
}
}
Jobs (Superclass)
KindOfJob(Thinking about it)
Pilot is a job so it'll need the "Job" variables and methods
Truck driver is a job so it'll need the "Job" variables and methods
Jobs class will be dependent of some classes, like ePlayer class to see if the player is using a checkpoint
And now my mind just exploded about the desing
I really appreciate any help about this or a link where I can learn about OOP desing, that to be honest, seems to be much more difficult than debugging a 100k lines non-OO program.