Refactoring existing methods to their own classes
Heya, back with more java questions. No example code needed, I need advice honestly. For you to understand, let me briefly explain what I'm assigned to do. If you wanna just get down to my question, skip to the bottom: My assignment asks me to refactor an existing set of code of a Hospital system. The new system is to have the tasks be their own class (commands) extended by a super that checks the status of them, and also handles their exceptions. Currently, the Hospital class used to handle all input and output calls, including storage of objects such as doctors and patients. I've since restructured it so that all I/O is assigned to an consoleIO class. However ... the issue I have is when giving each method its own class under the command package, calling them more than once is a problem, especially when one method depends upon another to acquire information. The class in question assigns a patient to a doctor, but that calls upon the patientData class. The IDE gives me a warning that the compiler will expect a method call, not a class call. So I'm unsure what method of approach I should use when I'm required to make these tasks a class of their own, and be called more than once. Maybe the best way I can ask this question is: When converting a method to its own class, how should I organize it? Should or shouldn't the constructor do everything? How should I approach calling and recalling the class? If I'm glossing over the obvious, please do point it out. Or, if I'm still too vague, let me know. Thanks in advance!