\begin{lgrind} \File{2.java},{14:03},{Jul 6 1997} \L{\LB{\C{}\1\* ========================================================================}} \L{\LB{_\*}} \L{\LB{_\* File : CarSim.java}} \L{\LB{_\* Version : 1.0}} \L{\LB{_\* Description : An applet that simulate a car moving around an assembly}} \L{\LB{_\* line. Users have the opportunity to select objects from}} \L{\LB{_\* the simulation to show its internals. Movement of the}} \L{\LB{_\* building car can be continuous or step by step through}} \L{\LB{_\* the use of buttons.}} \L{\LB{_\* Written by : Vi Huynh}} \L{\LB{_\* Creation date : 18 September 1996}} \L{\LB{_\* Last modified : 17 December 1996}} \L{\LB{_\*}} \L{\LB{_\* ======================================================================== \*\1\CE{}}} \L{\LB{}} \L{\LB{\C{}\1\1_ include the necessary packages and their classes}} \CE{}\L{\LB{\K{import}_\V{java}.\V{awt}.\*;}} \L{\LB{\K{import}_\V{java}.\V{awt}.\V{image}.\*;}} \L{\LB{\K{import}_\V{java}.\V{applet}.\V{Applet};}} \L{\LB{\K{import}_\V{java}.\V{util}.\V{Vector};}} \L{\LB{}} \L{\LB{\C{}\1\* ========== CarSim.class begins =========================================}} \L{\LB{_\*}} \L{\LB{_\* Class : CarSim}} \L{\LB{_\* Inherits from : Applet}} \L{\LB{_\* Description : The controlling class that will start the applet. Construct}} \L{\LB{_\* the user interface for the simulation and display the}} \L{\LB{_\* instruction. Provide button actions in events related to}} \L{\LB{_\* this class. Controls the starting and stopping of the}} \L{\LB{_\* animator thread, which is used to simulate the car object.}} \L{\LB{_\* Written by : Vi Huynh}} \L{\LB{_\* Creation date : 2 October 1996}} \L{\LB{_\* Last modified : 17 December 1996}} \L{\LB{_\*}} \L{\LB{_\* ======================================================================== \*\1\CE{}}} \L{\LB{\K{public}_\K{class}_\V{CarSim}_\K{extends}_\V{Applet}}} \L{\LB{\{}} \L{\LB{___\C{}\1\1_ instance variables}} \CE{}\L{\LB{___\V{Button}_\V{startButton};}} \L{\LB{___\V{Button}_\V{stopButton};}} \L{\LB{___\V{Button}_\V{forwardButton};}} \L{\LB{___\V{Button}_\V{backwardButton};}} \L{\LB{___\V{FactoryCanvas}_\V{factoryImage};}} \L{\LB{___\V{DetailsPanel}_\V{objectInfoPanel};}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method : init}} \L{\LB{____\* Return type : void}} \L{\LB{____\* Arguments : none}} \L{\LB{____\* Description : Provide initialisation to the applet when it starts. Set}} \L{\LB{____\* up the user interface and instruction to be displayed.}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{public}_\K{void}_\V{init}()}} \L{\LB{___\{}} \L{\LB{______\C{}\1\* set layout to BorderLayout and position components in place \*\1\CE{}}} \L{\LB{______\V{setLayout}(\K{new}_\V{BorderLayout}());}} \L{\LB{}} \L{\LB{______\V{Label}_\V{title}_=_\K{new}_\V{Label}(\S{}\"Car_Factory_Simulation\"\SE{},_\V{Label}.\V{CENTER});}} \L{\LB{______\V{title}.\V{setFont}(\K{new}_\V{Font}(\S{}\"Helvetica\"\SE{},_\V{Font}.\V{BOLD},_16));}} \L{\LB{______\V{add}(\S{}\"North\"\SE{},_\V{title});}} \L{\LB{}} \L{\LB{______\V{factoryImage}_=_\K{new}_\V{FactoryCanvas}(\K{this});}} \L{\LB{______\V{add}(\S{}\"West\"\SE{},_\V{factoryImage});}} \L{\LB{}} \L{\LB{______\V{objectInfoPanel}_=_\K{new}_\V{DetailsPanel}();}} \L{\LB{______\V{add}(\S{}\"East\"\SE{},_\V{objectInfoPanel});}} \L{\LB{}} \L{\LB{______\V{Panel}_\V{buttonPanel}_=_\K{new}_\V{Panel}();}} \L{\LB{______\V{buttonPanel}.\V{setFont}(\K{new}_\V{Font}(\S{}\"Helvetica\"\SE{},_\V{Font}.\V{PLAIN},_12));}} \L{\LB{______\V{buttonPanel}.\V{add}(\V{startButton}_=_\K{new}_\V{Button}(\S{}\"Start_Simulator\"\SE{}));}} \L{\LB{______\V{buttonPanel}.\V{add}(\V{stopButton}_=_\K{new}_\V{Button}(\S{}\"Pause_\"\SE{}));}} \L{\LB{______\V{buttonPanel}.\V{add}(\V{forwardButton}_=_\K{new}_\V{Button}(\S{}\"Forward_Step\"\SE{}));}} \L{\LB{______\V{buttonPanel}.\V{add}(\V{backwardButton}_=_\K{new}_\V{Button}(\S{}\"Backward_Step\"\SE{}));}} \L{\LB{______\V{add}(\S{}\"South\"\SE{},_\V{buttonPanel});}} \L{\LB{}} \L{\LB{______\C{}\1\1_ initial button states}} \CE{}\L{\LB{______\V{startButton}.\V{disable}();}} \L{\LB{______\V{stopButton}.\V{disable}();}} \L{\LB{______\V{forwardButton}.\V{disable}();}} \L{\LB{______\V{backwardButton}.\V{disable}();}} \L{\LB{}} \L{\LB{______\V{setInstruction}();___\C{}\1\1_ display instructions}} \CE{}\L{\LB{}} \L{\LB{______\V{validate}();_\C{}\1\1_ validates the applet to display all components within}} \CE{}\L{\LB{___\}}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method : setInstrunction}} \L{\LB{____\* Return type : void}} \L{\LB{____\* Arguments : none}} \L{\LB{____\* Description : Provide the applet with the instruction needed for the}} \L{\LB{____\* simulation.}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{private}_\K{void}_\V{setInstruction}()}} \L{\LB{___\{}} \L{\LB{______\V{objectInfoPanel}.\V{appendInstrArea}(\S{}\"At_the_start,_the_simulation_is_inactive.\2n\"\SE{});}} \L{\LB{______\V{objectInfoPanel}.\V{appendInstrArea}(\S{}\"Click_on_the_Start_Simulator_button\2n\"\SE{});}} \L{\LB{______\V{objectInfoPanel}.\V{appendInstrArea}(\S{}\"to_activate_the_simulation._Once_active\2n\"\SE{});}} \L{\LB{______\V{objectInfoPanel}.\V{appendInstrArea}(\S{}\"you_have_the_option_to_pause\1resume\2n\"\SE{});}} \L{\LB{______\V{objectInfoPanel}.\V{appendInstrArea}(\S{}\"the_simulator._There_are_two_extra\2n\"\SE{});}} \L{\LB{______\V{objectInfoPanel}.\V{appendInstrArea}(\S{}\"buttons_which_are_greyed_out.__These_\2n\"\SE{});}} \L{\LB{______\V{objectInfoPanel}.\V{appendInstrArea}(\S{}\"buttons_will_be_actived_upon_\2n\"\SE{});}} \L{\LB{______\V{objectInfoPanel}.\V{appendInstrArea}(\S{}\"pressing_the_pause_button.__This_two\2n\"\SE{});}} \L{\LB{______\V{objectInfoPanel}.\V{appendInstrArea}(\S{}\"buttons_allow_you_to_step_through\2n\"\SE{});}} \L{\LB{______\V{objectInfoPanel}.\V{appendInstrArea}(\S{}\"the_simulation_step_by_step_in_both\2n\"\SE{});}} \L{\LB{______\V{objectInfoPanel}.\V{appendInstrArea}(\S{}\"directions_\-_forth_and_back.__In_\2n\"\SE{});}} \L{\LB{______\V{objectInfoPanel}.\V{appendInstrArea}(\S{}\"either_mode,_when_the_simulator_is\2n\"\SE{});}} \L{\LB{______\V{objectInfoPanel}.\V{appendInstrArea}(\S{}\"active_there_are_objects_running.\2n\"\SE{});}} \L{\LB{______\V{objectInfoPanel}.\V{appendInstrArea}(\S{}\"Try_and_select_anything_to_see_where\2n\"\SE{});}} \L{\LB{______\V{objectInfoPanel}.\V{appendInstrArea}(\S{}\"these_objects_are.__For_example,_you_\2n\"\SE{});}} \L{\LB{______\V{objectInfoPanel}.\V{appendInstrArea}(\S{}\"can_select_the_car_and_that_will_\2n\"\SE{});}} \L{\LB{______\V{objectInfoPanel}.\V{appendInstrArea}(\S{}\"display_the_internals_of_that_object.\2n\"\SE{});}} \L{\LB{______\V{objectInfoPanel}.\V{appendInstrArea}(\S{}\"You_can_see_all_the_details_on_the\2n\"\SE{});}} \L{\LB{______\V{objectInfoPanel}.\V{appendInstrArea}(\S{}\"right\-handed_side_of_the_image._Play\2n\"\SE{});}} \L{\LB{______\V{objectInfoPanel}.\V{appendInstrArea}(\S{}\"around_and_you_will_see_more_objects.\2n\"\SE{});}} \L{\LB{______\V{objectInfoPanel}.\V{appendInstrArea}(\S{}\"Enjoy!\2n\"\SE{});}} \L{\LB{___\}}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method : start}} \L{\LB{____\* Return type : void}} \L{\LB{____\* Arguments : none}} \L{\LB{____\* Called by : The system when the applet is created.}} \L{\LB{____\* Description : To start the applet. Startup the animator thread if it}} \L{\LB{____\* hasn\'t yet.}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{public}_\K{void}_\V{start}()}} \L{\LB{___\{}} \L{\LB{______\K{if}_(\V{factoryImage}.\V{animator}_==_\K{null})}} \L{\LB{______\{}} \L{\LB{_________\V{factoryImage}.\V{animator}_=_\K{new}_\V{Thread}(\V{factoryImage});}} \L{\LB{_________\V{factoryImage}.\V{animator}.\V{start}();}} \L{\LB{______\}}} \L{\LB{___\}}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method : stop}} \L{\LB{____\* Return type : void}} \L{\LB{____\* Arguments : none}} \L{\LB{____\* Description : Stops the applet. It is called when the applet is no}} \L{\LB{____\* longer visible on screen. Reset animator thread to null.}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{public}_\K{void}_\V{stop}()}} \L{\LB{___\{}} \L{\LB{______\V{factoryImage}.\V{animator}_=_\K{null};}} \L{\LB{___\}}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method : action}} \L{\LB{____\* Return type : boolean to check if method performed successfully.}} \L{\LB{____\* Arguments : An Event object providing the event that occurred and an}} \L{\LB{____\* Object that received the event.}} \L{\LB{____\* Description : Carry out the actions for each button that is clicked.}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{public}_\K{boolean}_\V{action}(\V{Event}_\V{event},_\V{Object}_\V{arg})}} \L{\LB{___\{}} \L{\LB{______\K{boolean}_\V{paused};__\C{}\1\1_ set the paused state}} \CE{}\L{\LB{}} \L{\LB{______\K{if}_(\V{event}.\V{target}_==_\V{startButton})}} \L{\LB{______\{}} \L{\LB{_________\V{paused}_=_\K{false};}} \L{\LB{_________\V{factoryImage}.\V{startSimulator}(\V{paused});}} \L{\LB{_________\V{stopButton}.\V{setLabel}(\S{}\"Pause\"\SE{});}} \L{\LB{_________\V{stopButton}.\V{enable}();}} \L{\LB{_________\V{forwardButton}.\V{disable}();}} \L{\LB{_________\V{backwardButton}.\V{disable}();}} \L{\LB{_________\K{return}_\K{true};}} \L{\LB{______\}}} \L{\LB{______\K{else}_\K{if}_(\S{}\"Pause\"\SE{}.\V{equals}(\V{arg}))}} \L{\LB{______\{}} \L{\LB{_________\V{paused}_=_\K{true};}} \L{\LB{_________\V{factoryImage}.\V{proceedSimulator}(\V{paused});}} \L{\LB{_________\V{stopButton}.\V{setLabel}(\S{}\"Resume\"\SE{});}} \L{\LB{_________\V{forwardButton}.\V{enable}();}} \L{\LB{_________\V{backwardButton}.\V{enable}();}} \L{\LB{_________\K{return}_\K{true};}} \L{\LB{______\}}} \L{\LB{______\K{else}_\K{if}_(\S{}\"Resume\"\SE{}.\V{equals}(\V{arg}))}} \L{\LB{______\{}} \L{\LB{_________\V{paused}_=_\K{false};}} \L{\LB{_________\V{factoryImage}.\V{proceedSimulator}(\V{paused});}} \L{\LB{_________\V{stopButton}.\V{setLabel}(\S{}\"Pause\"\SE{});}} \L{\LB{_________\V{forwardButton}.\V{disable}();}} \L{\LB{_________\V{backwardButton}.\V{disable}();}} \L{\LB{_________\K{return}_\K{true};}} \L{\LB{______\}}} \L{\LB{______\K{else}_\K{if}_(\V{event}.\V{target}_==_\V{forwardButton})}} \L{\LB{______\{}} \L{\LB{_________\V{factoryImage}.\V{forwardStep}();}} \L{\LB{_________\K{return}_\K{true};}} \L{\LB{______\}}} \L{\LB{______\K{else}_\K{if}_(\V{event}.\V{target}_==_\V{backwardButton})}} \L{\LB{______\{}} \L{\LB{_________\V{factoryImage}.\V{backwardStep}();}} \L{\LB{_________\K{return}_\K{true};}} \L{\LB{______\}}} \L{\LB{______\K{return}_\K{false};}} \L{\LB{___\}}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method : reset}} \L{\LB{____\* Return type : void}} \L{\LB{____\* Arguments : none}} \L{\LB{____\* Description : Set the button states when simulator is about to start.}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{public}_\K{void}_\V{reset}()}} \L{\LB{___\{}} \L{\LB{______\V{startButton}.\V{enable}();}} \L{\LB{______\V{stopButton}.\V{disable}();}} \L{\LB{______\V{forwardButton}.\V{disable}();}} \L{\LB{______\V{backwardButton}.\V{disable}();}} \L{\LB{___\}}} \L{\LB{\}}} \L{\LB{\C{}\1\* ========== CarSim.class ends ========== \*\1\CE{}}} \L{\LB{}} \L{\LB{\C{}\1\* ========== FactoryCanvas.class begins ==================================}} \L{\LB{_\*}} \L{\LB{_\* Class : FactoryCanvas}} \L{\LB{_\* Inherits from : Canvas}} \L{\LB{_\* Interface used : Runnable}} \L{\LB{_\* Description : Controls the displaying of the image used in the applet}} \L{\LB{_\* and the thread that run the animation. Provide support}} \L{\LB{_\* to user clicks on the image to activate individual objects}} \L{\LB{_\* used in the simulation.}} \L{\LB{_\* Written by : Vi Huynh}} \L{\LB{_\* Creation date : 4 October 1996}} \L{\LB{_\* Last modified : 17 December 1996}} \L{\LB{_\*}} \L{\LB{_\* ======================================================================== \*\1\CE{}}} \L{\LB{\K{class}_\V{FactoryCanvas}_\K{extends}_\V{Canvas}_\K{implements}_\V{Runnable}}} \L{\LB{\{}} \L{\LB{___\C{}\1\1_ constants use to indicate when to display construction parts}} \CE{}\L{\LB{___\K{static}_\K{final}_\K{int}_\V{ASSEMBLE\_WINDOW}_=_1;}} \L{\LB{___\K{static}_\K{final}_\K{int}_\V{ASSEMBLE\_FRONT\_MODULE}_=_4;}} \L{\LB{___\K{static}_\K{final}_\K{int}_\V{ASSEMBLE\_PANEL}_=_8;}} \L{\LB{___\K{static}_\K{final}_\K{int}_\V{ASSEMBLE\_CARPET}_=_2;}} \L{\LB{___\K{static}_\K{final}_\K{int}_\V{ASSEMBLE\_REAR\_PANEL}_=_5;}} \L{\LB{___\K{static}_\K{final}_\K{int}_\V{ASSEMBLE\_OPERATING\_MATERIALS}_=_9;}} \L{\LB{___\K{static}_\K{final}_\K{int}_\V{ASSEMBLE\_WIRING}_=_0;}} \L{\LB{___\K{static}_\K{final}_\K{int}_\V{ASSEMBLE\_SHOCK}_=_3;}} \L{\LB{___\K{static}_\K{final}_\K{int}_\V{ASSEMBLE\_DRIVE\_MODULE}_=_7;}} \L{\LB{}} \L{\LB{___\K{public}_\V{Thread}_\V{animator}_=_\K{null};_\C{}\1\1_ thread indicator used in simulation}} \CE{}\L{\LB{}} \L{\LB{___\C{}\1\1_ instance variables}} \CE{}\L{\LB{___\V{CarSim}_\V{parent};}} \L{\LB{___\V{Image}_\V{background};}} \L{\LB{___\V{Image}_\V{car};}} \L{\LB{___\V{Image}_\V{offImage};}} \L{\LB{___\V{Graphics}_\V{offGraphics};}} \L{\LB{___\K{int}_\V{width},_\V{height};}} \L{\LB{___\K{boolean}_\V{paused};}} \L{\LB{___\K{boolean}_\V{endOfAssembly};}} \L{\LB{___\V{Car}_\V{movingCar};}} \L{\LB{___\V{StackTower}_\V{aStackTower};}} \L{\LB{___\V{CarWindowsComponent}_\V{aCarWindows};}} \L{\LB{___\V{CoolerComponent}_\V{aCooler};}} \L{\LB{___\V{LightsComponent}_\V{aLights};}} \L{\LB{___\V{FrontPanelComponent}_\V{aFrontPanel};}} \L{\LB{___\V{FrontModule}_\V{frontModule};}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method : FactoryCanvas}} \L{\LB{____\* Return type : none}} \L{\LB{____\* Arguments : CarSim - to keep a reference to the class that control}} \L{\LB{____\* the applet.}} \L{\LB{____\* Description : Constructor for FactoryCanvas class.}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{public}_\V{FactoryCanvas}(\V{CarSim}_\V{parent})}} \L{\LB{___\{}} \L{\LB{______\K{this}.\V{parent}_=_\V{parent};}} \L{\LB{______\V{paused}_=_\K{true};}} \L{\LB{______\V{endOfAssembly}_=_\K{false};}} \L{\LB{}} \L{\LB{______\C{}\1\1_ load background for simulator}} \CE{}\L{\LB{______\V{background}_=_\V{parent}.\V{getImage}(\V{parent}.\V{getDocumentBase}(),_\S{}\"factory.gif\"\SE{});}} \L{\LB{}} \L{\LB{______\V{Car}.\V{makeImage}(\V{parent});_\C{}\1\1_ call to load car images}} \CE{}\L{\LB{}} \L{\LB{______\V{assemblyComponentInit}();}} \L{\LB{}} \L{\LB{______\V{width}_=_522;}} \L{\LB{______\V{height}_=_463;}} \L{\LB{______\V{resize}(\V{width},_\V{height});_\C{}\1\1_ allocate proper size for background}} \CE{}\L{\LB{}} \L{\LB{______\C{}\1\1_ create initial image screen prior to loading the image on the screen}} \CE{}\L{\LB{______\V{offImage}_=_\V{parent}.\V{createImage}(\V{width},_\V{height});}} \L{\LB{______\V{offGraphics}_=_\V{offImage}.\V{getGraphics}();_\C{}\1\1_ create Graphics object}} \CE{}\L{\LB{______\V{offGraphics}.\V{setColor}(\V{Color}.\V{gray});}} \L{\LB{______\V{offGraphics}.\V{fillRect}(0,_0,_\V{width},_\V{height});}} \L{\LB{______\V{offGraphics}.\V{setColor}(\V{Color}.\V{white});}} \L{\LB{______\V{offGraphics}.\V{drawString}(\S{}\"Loading_Car_Factory_Image.\,.\,.\"\SE{},_20,_\V{height}_\-_20);}} \L{\LB{___\}}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method : startSimulator}} \L{\LB{____\* Return type : none}} \L{\LB{____\* Arguments : boolean value for the paused state}} \L{\LB{____\* Description : Activate the simulator}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{public}_\K{void}_\V{startSimulator}(\K{boolean}_\V{pauseValue})}} \L{\LB{___\{}} \L{\LB{______\V{assemblyComponentInit}();}} \L{\LB{______\V{movingCar}.\V{startMoving}();}} \L{\LB{______\V{paused}_=_\V{pauseValue};}} \L{\LB{___\}}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method : proceedSimulator}} \L{\LB{____\* Return type : void}} \L{\LB{____\* Arguments : boolean value for paused state}} \L{\LB{____\* Description : Set the state of simulator relating to the paused state.}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{public}_\K{void}_\V{proceedSimulator}(\K{boolean}_\V{stop})}} \L{\LB{___\{}} \L{\LB{______\V{paused}_=_\V{stop};}} \L{\LB{___\}}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method : run}} \L{\LB{____\* Return type : void}} \L{\LB{____\* Arguments : none}} \L{\LB{____\* Description : Override run in Runnable interface. Provide the body of}} \L{\LB{____\* the thread, which is used to animate the simulator.}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{public}_\K{void}_\V{run}()}} \L{\LB{___\{}} \L{\LB{______\C{}\1\1_ Start code - written by Robert Temple}} \CE{}\L{\LB{______\C{}\1\1_ Load background image as quick as possible}} \CE{}\L{\LB{______\K{while}_((\V{parent}.\V{checkImage}(\V{background},_\V{parent})_\&_\V{ImageObserver}.\V{ALLBITS})_==_0)}} \L{\LB{______\{}} \L{\LB{_________\V{repaint}();}} \L{\LB{_________\K{try}}} \L{\LB{_________\{}} \L{\LB{____________\V{Thread}.\V{sleep}(250);_\C{}\1\1_ quarter of a second interval wait}} \CE{}\L{\LB{_________\}}} \L{\LB{_________\K{catch}_(\V{InterruptedException}_\V{threadException})_\{\}}} \L{\LB{______\}}} \L{\LB{}} \L{\LB{______\V{repaint}();__\C{}\1\1_ refresh the whole background image to screen}} \CE{}\L{\LB{}} \L{\LB{______((\V{CarSim})\V{getParent}()).\V{startButton}.\V{enable}();}} \L{\LB{______\C{}\1\1_ End code - modified by Vi Huynh}} \CE{}\L{\LB{}} \L{\LB{______\K{while}_(\V{Thread}.\V{currentThread}()_==_\V{animator})}} \L{\LB{______\{}} \L{\LB{_________\V{repaint}();_\C{}\1\1_ refresh screen with car placement}} \CE{}\L{\LB{}} \L{\LB{_________\K{if}_(\V{paused})}} \L{\LB{_________\{}} \L{\LB{____________\K{try}}} \L{\LB{____________\{}} \L{\LB{_______________\V{Thread}.\V{sleep}(1500);_\C{}\1\1_ one and a half second}} \CE{}\L{\LB{____________\}}} \L{\LB{____________\K{catch}_(\V{InterruptedException}_\V{threadException})_\{\}}} \L{\LB{_________\}}} \L{\LB{_________\K{else}}} \L{\LB{_________\{}} \L{\LB{____________\V{updateAssemblyLine}();_\C{}\1\1_ determine if any assembly component needs activation}} \CE{}\L{\LB{____________\K{if}_(\V{movingCar}.\V{row}()_==_\V{movingCar}.\V{maxRow}())}} \L{\LB{____________\{}} \L{\LB{_______________\V{repaint}();_\C{}\1\1_ try to refresh}} \CE{}\L{\LB{_______________\K{try}}} \L{\LB{_______________\{}} \L{\LB{__________________\V{Thread}.\V{sleep}(1000);_\C{}\1\1_ a second interval}} \CE{}\L{\LB{_______________\}}} \L{\LB{_______________\K{catch}_(\V{InterruptedException}_\V{threadException})_\{_\K{break};_\}}} \L{\LB{_______________\V{repaint}();_\C{}\1\1_ refresh if prior didn\'t work}} \CE{}\L{\LB{_______________\V{movingCar}_=_\V{aStackTower}.\V{getCar}();}} \L{\LB{_______________\V{carExist}();}} \L{\LB{____________\}}} \L{\LB{____________\K{else}}} \L{\LB{____________\V{movingCar}.\V{move}();_\C{}\1\1_ move current car object}} \CE{}\L{\LB{____________\K{try}}} \L{\LB{____________\{___\C{}\1\1_ control the speed of animation}} \CE{}\L{\LB{_______________\V{Thread}.\V{sleep}(200);_\C{}\1\1_ half a second interval}} \CE{}\L{\LB{____________\}}} \L{\LB{____________\K{catch}_(\V{InterruptedException}_\V{threadException})_\{_\K{break};_\}}} \L{\LB{_________\}}} \L{\LB{______\}}} \L{\LB{___\}}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method : paint}} \L{\LB{____\* Return type : void}} \L{\LB{____\* Arguments : the Graphics window that display the image on screen}} \L{\LB{____\* Description : Override the Canvas class method.}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{public}_\K{void}_\V{paint}(\V{Graphics}_\V{paintCanvas})}} \L{\LB{___\{}} \L{\LB{______\V{update}(\V{paintCanvas});_\C{}\1\1_ call update to display the updated animation}} \CE{}\L{\LB{___\}}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method : update}} \L{\LB{____\* Return type : void}} \L{\LB{____\* Arguments : the Graphics window that display the image on screen}} \L{\LB{____\* Description : Override the Component class method. Setup the animation}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{public}_\K{void}_\V{update}(\V{Graphics}_\V{updateCanvas})}} \L{\LB{___\{}} \L{\LB{______\V{offGraphics}.\V{drawImage}(\V{background},_0,_0,_\V{parent});}} \L{\LB{______\V{movingCar}.\V{drawCar}(\V{offGraphics},_\V{parent});}} \L{\LB{______\V{updateCanvas}.\V{drawImage}(\V{offImage},_0,_0,_\V{parent});}} \L{\LB{___\}}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method : mouseDown}} \L{\LB{____\* Return type : boolean value. Determine the success of operation.}} \L{\LB{____\* Arguments : An Event object and its x and y coordinates}} \L{\LB{____\* Description : Override the Component class method. Check if any of}} \L{\LB{____\* the objects on screen is clicked and call to display its}} \L{\LB{____\* details.}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{public}_\K{boolean}_\V{mouseDown}(\V{Event}_\V{e},_\K{int}_\V{x},_\K{int}_\V{y})}} \L{\LB{___\{}} \L{\LB{______\K{if}_(\V{movingCar}.\V{clickedUpon}(\V{x},_\V{y}))}} \L{\LB{______\{}} \L{\LB{_________\V{movingCar}.\V{showInternals}(\V{movingCar});}} \L{\LB{_________\K{return}_\K{true};}} \L{\LB{______\}}} \L{\LB{______\K{if}_(\V{aStackTower}.\V{clickedUpon}(\V{x},_\V{y}))}} \L{\LB{______\{}} \L{\LB{_________\V{aStackTower}.\V{showInternals}(\V{aStackTower});}} \L{\LB{_________\K{return}_\K{true};}} \L{\LB{______\}}} \L{\LB{______\K{if}_(\V{aCarWindows}.\V{clickedUpon}(\V{x},_\V{y}))}} \L{\LB{______\{}} \L{\LB{_________\V{aCarWindows}.\V{showInternals}(\V{aCarWindows});}} \L{\LB{_________\K{return}_\K{true};}} \L{\LB{______\}}} \L{\LB{______\K{if}_(\V{aCooler}.\V{clickedUpon}(\V{x},_\V{y}))}} \L{\LB{______\{}} \L{\LB{_________\V{aCooler}.\V{showInternals}(\V{aCooler});}} \L{\LB{_________\K{return}_\K{true};}} \L{\LB{______\}}} \L{\LB{______\K{if}_(\V{aLights}.\V{clickedUpon}(\V{x},_\V{y}))}} \L{\LB{______\{}} \L{\LB{_________\V{aLights}.\V{showInternals}(\V{aLights});}} \L{\LB{_________\K{return}_\K{true};}} \L{\LB{______\}}} \L{\LB{______\K{if}_(\V{aFrontPanel}.\V{clickedUpon}(\V{x},_\V{y}))}} \L{\LB{______\{}} \L{\LB{_________\V{aFrontPanel}.\V{showInternals}(\V{aFrontPanel});}} \L{\LB{_________\K{return}_\K{true};}} \L{\LB{______\}}} \L{\LB{______\K{if}_(\V{frontModule}.\V{clickedUpon}(\V{x},_\V{y}))}} \L{\LB{______\{}} \L{\LB{_________\V{frontModule}.\V{showInternals}(\V{frontModule});}} \L{\LB{_________\K{return}_\K{true};}} \L{\LB{______\}}} \L{\LB{}} \L{\LB{______\V{parent}.\V{objectInfoPanel}.\V{clearAll}();}} \L{\LB{______\K{return}_\K{true};}} \L{\LB{___\}}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method : forwardStep}} \L{\LB{____\* Return type : void}} \L{\LB{____\* Arguments : none}} \L{\LB{____\* Description : Perform a forward step action when user clicked the}} \L{\LB{____\* forward step button. Get next car object if the current}} \L{\LB{____\* car object has finish going around the assembly line.}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{public}_\K{void}_\V{forwardStep}()}} \L{\LB{___\{}} \L{\LB{______\K{if}_(\V{endOfAssembly})}} \L{\LB{______\{}} \L{\LB{_________\V{movingCar}_=_\V{aStackTower}.\V{getCar}();}} \L{\LB{_________\V{carExist}();}} \L{\LB{_________\V{endOfAssembly}_=_\K{false};}} \L{\LB{______\}}} \L{\LB{______\K{else}}} \L{\LB{_________\V{movingCar}.\V{moveForward}();}} \L{\LB{______\V{repaint}();__\C{}\1\1_ udpate screen image}} \CE{}\L{\LB{______\V{updateAssemblyLine}();}} \L{\LB{______\C{}\1\1_ check end of assembly line reached}} \CE{}\L{\LB{______\K{if}_(\V{movingCar}.\V{row}()_==_\V{movingCar}.\V{maxRow}())}} \L{\LB{_________\V{endOfAssembly}_=_\K{true};}} \L{\LB{___\}}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method : backwardStep}} \L{\LB{____\* Return type : void}} \L{\LB{____\* Arguments : none}} \L{\LB{____\* Description : Perform the backward step of current car object.}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{public}_\K{void}_\V{backwardStep}()}} \L{\LB{___\{}} \L{\LB{______\V{movingCar}.\V{moveBackward}();}} \L{\LB{______\V{repaint}();}} \L{\LB{______\V{updateAssemblyLine}();}} \L{\LB{______\C{}\1\1_ reset boolean if previous car position is at end of assembly line}} \CE{}\L{\LB{______\K{if}_(\V{movingCar}.\V{row}()_==_(\V{movingCar}.\V{maxRow}()_\-_1))}} \L{\LB{_________\V{endOfAssembly}_=_\K{false};}} \L{\LB{___\}}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method : assemblyComponentInit}} \L{\LB{____\* Return type : void}} \L{\LB{____\* Arguments : none}} \L{\LB{____\* Description : Create all necessary instances of assembly components}} \L{\LB{____\* and setup the number of car objects that will be used}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{private}_\K{void}_\V{assemblyComponentInit}()}} \L{\LB{___\{}} \L{\LB{______\C{}\1\1_ setup number of car objects to use}} \CE{}\L{\LB{______\V{Vector}_\V{cars}_=_\K{new}_\V{Vector}(5);}} \L{\LB{______\V{cars}.\V{addElement}(\K{new}_\V{Car}(\V{parent}));}} \L{\LB{______\V{cars}.\V{addElement}(\K{new}_\V{Car}(\V{parent}));}} \L{\LB{______\V{cars}.\V{addElement}(\K{new}_\V{Car}(\V{parent}));}} \L{\LB{}} \L{\LB{______\V{aStackTower}_=_\K{new}_\V{StackTower}(\V{parent},_\V{cars});}} \L{\LB{______\V{aCarWindows}_=_\K{new}_\V{CarWindowsComponent}(\V{parent});}} \L{\LB{______\V{aCooler}_=_\K{new}_\V{CoolerComponent}(\V{parent});}} \L{\LB{______\V{aLights}_=_\K{new}_\V{LightsComponent}(\V{parent});}} \L{\LB{______\V{aFrontPanel}_=_\K{new}_\V{FrontPanelComponent}(\V{parent});}} \L{\LB{______\V{frontModule}_=_\K{new}_\V{FrontModule}(\V{parent});}} \L{\LB{}} \L{\LB{______\V{movingCar}_=_\V{aStackTower}.\V{getCar}();_\C{}\1\1_ retrieve one car from stack tower}} \CE{}\L{\LB{___\}}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method : updateAssemblyLine}} \L{\LB{____\* Return type : void}} \L{\LB{____\* Arguments : none}} \L{\LB{____\* Description : Start the require assembly component when it is their}} \L{\LB{____\* turn to assemble.}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{private}_\K{void}_\V{updateAssemblyLine}()}} \L{\LB{___\{}} \L{\LB{______\K{switch}_(\V{movingCar}.\V{row}())}} \L{\LB{______\{}} \L{\LB{_________\K{case}_\V{ASSEMBLE\_WINDOW}_:}} \L{\LB{____________\V{aCarWindows}.\V{beginWindowsAssembling}();}} \L{\LB{____________\K{break};}} \L{\LB{_________\K{case}_\V{ASSEMBLE\_FRONT\_MODULE}_:}} \L{\LB{____________\V{frontModule}.\V{assembleModule}(\V{aCooler},_\V{aLights});}} \L{\LB{____________\K{break};}} \L{\LB{_________\K{case}_\V{ASSEMBLE\_PANEL}_:}} \L{\LB{____________\V{aFrontPanel}.\V{beginFrontPanelAssembling}();}} \L{\LB{____________\K{break};}} \L{\LB{_________\K{case}_\V{ASSEMBLE\_CARPET}_:}} \L{\LB{_________\K{case}_\V{ASSEMBLE\_REAR\_PANEL}_:}} \L{\LB{_________\K{case}_\V{ASSEMBLE\_OPERATING\_MATERIALS}_:}} \L{\LB{_________\K{case}_\V{ASSEMBLE\_WIRING}_:}} \L{\LB{_________\K{case}_\V{ASSEMBLE\_SHOCK}_:}} \L{\LB{_________\K{case}_\V{ASSEMBLE\_DRIVE\_MODULE}_:}} \L{\LB{____________\V{parent}.\V{showStatus}(\S{}\"\"\SE{});}} \L{\LB{______\}}} \L{\LB{___\}}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method : carExist}} \L{\LB{____\* Return type : void}} \L{\LB{____\* Arguments : none}} \L{\LB{____\* Description : Check if any more car object from stack tower. Reset}} \L{\LB{____\* if true, otherwise, set initial car movement position}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{private}_\K{void}_\V{carExist}()}} \L{\LB{___\{}} \L{\LB{______\K{if}_(\V{movingCar}_==_\K{null})}} \L{\LB{______\{___\C{}\1\1_ no more cars in stack tower}} \CE{}\L{\LB{_________\V{paused}_=_\K{true};}} \L{\LB{_________\V{parent}.\V{reset}();}} \L{\LB{_________\V{movingCar}_=_\K{new}_\V{Car}(\V{parent});}} \L{\LB{______\}}} \L{\LB{______\K{else}}} \L{\LB{_________\V{movingCar}.\V{startMoving}();}} \L{\LB{___\}}} \L{\LB{\}}} \L{\LB{\C{}\1\* ========== FactoryCanvas.class ends ========== \*\1\CE{}}} \L{\LB{}} \L{\LB{\C{}\1\* ========== Car.class begins ============================================}} \L{\LB{_\*}} \L{\LB{_\* Class : Car}} \L{\LB{_\* Inherits from : Object}} \L{\LB{_\* Description : Control the car that is shown on screen. Provide the}} \L{\LB{_\* movement controls}} \L{\LB{_\* Written by : Vi Huynh}} \L{\LB{_\* Creation date : 9 October 1996}} \L{\LB{_\* Last modified : 17 December 1996}} \L{\LB{_\*}} \L{\LB{_\* ======================================================================== \*\1\CE{}}} \L{\LB{\K{class}_\V{Car}_\K{extends}_\V{Object}}} \L{\LB{\{}} \L{\LB{___\C{}\1\1_ directional and positional constants}} \CE{}\L{\LB{___\K{static}_\K{final}_\K{int}_\V{DOWN}_=_0;}} \L{\LB{___\K{static}_\K{final}_\K{int}_\V{RIGHT}_=_1;}} \L{\LB{___\K{static}_\K{final}_\K{int}_\V{UP}_=_2;}} \L{\LB{___\K{static}_\K{final}_\K{int}_\V{FINISHED}_=_3;}} \L{\LB{___\K{static}_\K{final}_\K{int}_\V{INIT\_X}_=_122;_\C{}\1\1_ initial position of car [X,Y]}} \CE{}\L{\LB{___\K{static}_\K{final}_\K{int}_\V{INIT\_Y}_=_65;}} \L{\LB{___\K{static}_\K{final}_\K{int}_\V{OFFSCREEN\_X}_=_522;}} \L{\LB{___\K{static}_\K{final}_\K{int}_\V{OFFSCREEN\_Y}_=_0;}} \L{\LB{}} \L{\LB{___\C{}\1\1_ positions to the car object when moving step by step}} \CE{}\L{\LB{___\K{static}_\K{final}_\K{int}[\,][\,]_\V{positions}_=_\{\{122,65\},\{122,118\},\{122,172\},\{122,224\},}} \L{\LB{_____________________________________\{145,291\},\{209,291\},\{271,291\},\{341,291\},}} \L{\LB{_____________________________________\{400,242\},\{400,185\},\{400,128\},\{400,73\},}} \L{\LB{_____________________________________\{400,30\},\{471,4\}\};}} \L{\LB{___\C{}\1\1_ other constants}} \CE{}\L{\LB{___\K{static}_\K{final}_\K{int}_\V{MAX\_ROW}_=_13;}} \L{\LB{___\K{static}_\K{final}_\K{int}_\V{INIT\_ROW}_=_0;}} \L{\LB{___\K{static}_\K{final}_\K{int}_\V{SPEED}_=_4;}} \L{\LB{___\K{static}_\K{final}_\K{int}_\V{X\_DOWN}_=_122;}} \L{\LB{___\K{static}_\K{final}_\K{int}_\V{X\_UP}_=_400;}} \L{\LB{___\K{static}_\K{final}_\K{int}_\V{Y\_RIGHT}_=_291;}} \L{\LB{___\K{static}_\K{final}_\K{int}_\V{LAST\_DOWN}_=_3;}} \L{\LB{___\K{static}_\K{final}_\K{int}_\V{LAST\_RIGHT}_=_7;}} \L{\LB{___\K{static}_\K{final}_\K{int}_\V{LAST\_UP}_=_12;}} \L{\LB{___\K{static}_\K{final}_\K{int}_\V{COMPLETED}_=_4;}} \L{\LB{___\K{static}_\K{final}_\K{int}_\V{LAST\_X\_RIGHT}_=_340;}} \L{\LB{___\K{static}_\K{final}_\K{int}_\V{LAST\_Y\_UP}_=_30;}} \L{\LB{___\K{static}_\K{final}_\K{int}_\V{LAST\_Y\_DOWN}_=_224;}} \L{\LB{___\K{static}_\K{final}_\K{int}_\V{FIRST\_Y\_UP}_=_242;}} \L{\LB{}} \L{\LB{___\C{}\1\1_ instance variables}} \CE{}\L{\LB{___\K{int}_\V{xPosition};}} \L{\LB{___\K{int}_\V{yPosition};}} \L{\LB{___\K{int}_\V{direction};}} \L{\LB{___\K{int}_\V{row}_=_\V{INIT\_ROW};}} \L{\LB{___\K{int}_\V{col}_=_0;}} \L{\LB{___\V{CarSim}_\V{parent};}} \L{\LB{}} \L{\LB{___\C{}\1\1_ class variable to store car images}} \CE{}\L{\LB{___\K{static}_\V{Image}[\,]_\V{carImages}_=_\K{new}_\V{Image}[4];}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method : makeImage}} \L{\LB{____\* Return type : void}} \L{\LB{____\* Arguments : a reference to CarSim object}} \L{\LB{____\* Description : Load the car images and store in carImages}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{public}_\K{static}_\K{void}_\V{makeImage}(\V{CarSim}_\V{app})}} \L{\LB{___\{}} \L{\LB{______\V{Vector}_\V{storeImages}_=_\K{new}_\V{Vector}();}} \L{\LB{}} \L{\LB{______\V{storeImages}.\V{addElement}(\V{app}.\V{getImage}(\V{app}.\V{getDocumentBase}(),_\V{app}.\V{getParameter}(\S{}\"down\"\SE{})));}} \L{\LB{______\V{storeImages}.\V{addElement}(\V{app}.\V{getImage}(\V{app}.\V{getDocumentBase}(),_\V{app}.\V{getParameter}(\S{}\"right\"\SE{})));}} \L{\LB{______\V{storeImages}.\V{addElement}(\V{app}.\V{getImage}(\V{app}.\V{getDocumentBase}(),_\V{app}.\V{getParameter}(\S{}\"up\"\SE{})));}} \L{\LB{______\V{storeImages}.\V{addElement}(\V{app}.\V{getImage}(\V{app}.\V{getDocumentBase}(),_\V{app}.\V{getParameter}(\S{}\"finished\"\SE{})));}} \L{\LB{}} \L{\LB{______\V{storeImages}.\V{copyInto}(\V{carImages});}} \L{\LB{___\}}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method : Car}} \L{\LB{____\* Return type : none}} \L{\LB{____\* Arguments : CarSim reference that will be used in this class}} \L{\LB{____\* Description : Constructor to Car class}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{public}_\V{Car}(\V{CarSim}_\V{parent})}} \L{\LB{___\{}} \L{\LB{______\K{this}.\V{parent}_=_\V{parent};}} \L{\LB{______\V{xPosition}_=_\V{OFFSCREEN\_X};_\C{}\1\1_ Initial position outside FactoryCanvas boundary}} \CE{}\L{\LB{______\V{yPosition}_=_\V{OFFSCREEN\_Y};}} \L{\LB{______\V{direction}_=_\V{DOWN};}} \L{\LB{___\}}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method : row}} \L{\LB{____\* Return type : integer value of row variable}} \L{\LB{____\* Arguments : none}} \L{\LB{____\* Description : Get row value.}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{public}_\K{int}_\V{row}()}} \L{\LB{___\{}} \L{\LB{______\K{return}_\V{row};}} \L{\LB{___\}}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method : maxRow}} \L{\LB{____\* Return type : integer value of MAX\_ROW constant}} \L{\LB{____\* Arguments : none}} \L{\LB{____\* Description : get MAX\_ROW value}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{public}_\K{int}_\V{maxRow}()}} \L{\LB{___\{}} \L{\LB{______\K{return}_\V{MAX\_ROW};}} \L{\LB{___\}}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method : startMoving}} \L{\LB{____\* Return type : void}} \L{\LB{____\* Arguments : none}} \L{\LB{____\* Description : Set the starting position of car object}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{public}_\K{void}_\V{startMoving}()}} \L{\LB{___\{}} \L{\LB{______\V{xPosition}_=_\V{INIT\_X};}} \L{\LB{______\V{yPosition}_=_\V{INIT\_Y};}} \L{\LB{______\V{row}_=_\V{INIT\_ROW};}} \L{\LB{______\V{direction}_=_\V{DOWN};}} \L{\LB{___\}}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method : setDirection}} \L{\LB{____\* Return type : value of direction}} \L{\LB{____\* Arguments : value of row}} \L{\LB{____\* Description : Determine the direction base on curent value of row}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{private}_\K{int}_\V{setDirection}(\K{int}_\V{currentRow})}} \L{\LB{___\{}} \L{\LB{______\K{int}_\V{newDirection}_=_\V{DOWN};}} \L{\LB{}} \L{\LB{______\K{if}_(\V{currentRow}_\>=_\V{INIT\_ROW}_\&\&_\V{currentRow}_\<=_\V{LAST\_DOWN})}} \L{\LB{_________\V{newDirection}_=_\V{DOWN};}} \L{\LB{______\K{else}_\K{if}_(\V{currentRow}_\>=_(\V{LAST\_DOWN}_+_1)_\&\&_\V{currentRow}_\<=_\V{LAST\_RIGHT})}} \L{\LB{_________\V{newDirection}_=_\V{RIGHT};}} \L{\LB{______\K{else}_\K{if}_(\V{currentRow}_\>=_(\V{LAST\_RIGHT}_+_1)_\&\&_\V{currentRow}_\<=_\V{LAST\_UP})}} \L{\LB{_________\V{newDirection}_=_\V{UP};}} \L{\LB{______\K{else}_\K{if}_(\V{currentRow}_==_\V{MAX\_ROW})}} \L{\LB{_________\V{newDirection}_=_\V{FINISHED};}} \L{\LB{______\K{return}_\V{newDirection};}} \L{\LB{___\}}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method : moveForward}} \L{\LB{____\* Return type : boolean - indicate the success of movement}} \L{\LB{____\* Arguments : none}} \L{\LB{____\* Description : Coordinate the forward movement for car object}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{public}_\K{boolean}_\V{moveForward}()}} \L{\LB{___\{}} \L{\LB{______\K{int}_\V{index}_=_0;}} \L{\LB{______\K{int}_\V{startRange}_=_0,_\V{endRange}_=_0;}} \L{\LB{}} \L{\LB{______\C{}\1\1_ determine where the car object is before moving the car to the next}} \CE{}\L{\LB{______\C{}\1\1_ component position on the factory image}} \CE{}\L{\LB{______\K{if}_(\V{xPosition}_==_\V{X\_DOWN})}} \L{\LB{______\{}} \L{\LB{_________\V{index}_=_\V{row};}} \L{\LB{_________\K{while}_(\V{index}_\<=_\V{LAST\_DOWN})}} \L{\LB{_________\{}} \L{\LB{____________\V{startRange}_=_\V{positions}[\V{index}][\V{col}+1];}} \L{\LB{____________\V{endRange}_=_\V{positions}[\V{index}+1][\V{col}+1];}} \L{\LB{____________\K{if}_(\V{yPosition}_\>=_\V{startRange}_\&\&_\V{yPosition}_\<=_\V{endRange})}} \L{\LB{____________\{}} \L{\LB{_______________\V{row}_=_\V{index}_+_1;}} \L{\LB{_______________\K{break};}} \L{\LB{____________\}}} \L{\LB{____________\V{index}++;}} \L{\LB{_________\}}} \L{\LB{______\}}} \L{\LB{______\K{else}_\K{if}_(\V{xPosition}_==_\V{X\_UP})}} \L{\LB{______\{}} \L{\LB{_________\V{index}_=_\V{row};}} \L{\LB{_________\K{while}_(\V{index}_\<=_\V{LAST\_UP})}} \L{\LB{_________\{}} \L{\LB{____________\V{startRange}_=_\V{positions}[\V{index}][\V{col}+1];}} \L{\LB{____________\K{if}_(\V{yPosition}_\>=_\V{startRange})}} \L{\LB{____________\{}} \L{\LB{_______________\V{row}_=_\V{index}_+_1;}} \L{\LB{_______________\K{break};}} \L{\LB{____________\}}} \L{\LB{____________\V{index}++;}} \L{\LB{_________\}}} \L{\LB{______\}}} \L{\LB{______\K{else}_\K{if}_(\V{yPosition}_==_\V{Y\_RIGHT})}} \L{\LB{______\{}} \L{\LB{_________\V{index}_=_\V{row};}} \L{\LB{_________\K{while}_(\V{index}_\<=_\V{LAST\_RIGHT})}} \L{\LB{_________\{}} \L{\LB{____________\V{startRange}_=_\V{positions}[\V{index}][\V{col}];}} \L{\LB{____________\V{endRange}_=_\V{positions}[\V{index}+1][\V{col}];}} \L{\LB{____________\K{if}_(\V{xPosition}_\>=_\V{startRange}_\&\&_\V{xPosition}_\<=_\V{endRange})}} \L{\LB{____________\{}} \L{\LB{_______________\V{row}_=_\V{index}_+_1;}} \L{\LB{_______________\K{break};}} \L{\LB{____________\}}} \L{\LB{____________\V{index}++;}} \L{\LB{_________\}}} \L{\LB{______\}}} \L{\LB{______\V{setCarCoordinates}();}} \L{\LB{______\V{direction}_=_\V{setDirection}(\V{row});}} \L{\LB{______\K{return}_\K{true};}} \L{\LB{___\}}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method : moveBackward}} \L{\LB{____\* Return type : boolean - indicate the success of movement}} \L{\LB{____\* Arguments : none}} \L{\LB{____\* Description : Coordinate the backward movement for car object}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{public}_\K{boolean}_\V{moveBackward}()}} \L{\LB{___\{}} \L{\LB{______\K{int}_\V{index}_=_\V{row};}} \L{\LB{______\K{int}_\V{startRange}_=_0,_\V{endRange}_=_0;}} \L{\LB{}} \L{\LB{______\K{if}_(\V{xPosition}_==_\V{X\_DOWN})}} \L{\LB{______\{}} \L{\LB{_________\K{while}_(\V{index}_\>=_(\V{INIT\_ROW}_+_1)_\&\&_\V{index}_\<=_\V{LAST\_DOWN})}} \L{\LB{_________\{}} \L{\LB{____________\V{startRange}_=_\V{positions}[\V{index}][\V{col}+1];}} \L{\LB{____________\V{endRange}_=_\V{positions}[\V{index}+1][\V{col}+1];}} \L{\LB{____________\K{if}_(\V{yPosition}_\>=_\V{startRange}_\&\&_\V{yPosition}_\<=_\V{endRange})}} \L{\LB{____________\{}} \L{\LB{_______________\V{row}_\-=_1;}} \L{\LB{_______________\K{break};}} \L{\LB{____________\}}} \L{\LB{____________\V{index}++;}} \L{\LB{_________\}}} \L{\LB{______\}}} \L{\LB{______\K{else}_\K{if}_(\V{xPosition}_==_\V{X\_UP})}} \L{\LB{______\{}} \L{\LB{_________\K{while}_(\V{index}_\<=_\V{LAST\_UP})}} \L{\LB{_________\{}} \L{\LB{____________\V{startRange}_=_\V{positions}[\V{index}][\V{col}+1];}} \L{\LB{____________\K{if}_(\V{yPosition}_\>=_\V{startRange})}} \L{\LB{____________\{}} \L{\LB{_______________\V{row}_\-=_1;}} \L{\LB{_______________\K{break};}} \L{\LB{____________\}}} \L{\LB{____________\V{index}++;}} \L{\LB{_________\}}} \L{\LB{______\}}} \L{\LB{______\K{else}_\K{if}_(\V{yPosition}_==_\V{Y\_RIGHT})}} \L{\LB{______\{}} \L{\LB{_________\K{while}_(\V{index}_\<=_\V{LAST\_RIGHT})}} \L{\LB{_________\{}} \L{\LB{____________\V{startRange}_=_\V{positions}[\V{index}][\V{col}];}} \L{\LB{____________\V{endRange}_=_\V{positions}[\V{index}+1][\V{col}];}} \L{\LB{____________\K{if}_(\V{xPosition}_\>=_\V{startRange}_\&\&_\V{xPosition}_\<=_\V{endRange})}} \L{\LB{____________\{}} \L{\LB{_______________\V{row}_\-=_1;}} \L{\LB{_______________\K{break};}} \L{\LB{____________\}}} \L{\LB{____________\V{index}++;}} \L{\LB{_________\}}} \L{\LB{______\}}} \L{\LB{______\K{else}_\K{if}_(\V{yPosition}_==_\V{COMPLETED})}} \L{\LB{______\{}} \L{\LB{_________\V{row}_\-=_1;}} \L{\LB{______\}}} \L{\LB{}} \L{\LB{______\V{setCarCoordinates}();}} \L{\LB{______\V{direction}_=_\V{setDirection}(\V{row});}} \L{\LB{______\K{return}_\K{true};}} \L{\LB{___\}}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method : setCarCoordinates}} \L{\LB{____\* Return type : void}} \L{\LB{____\* Arguments : none}} \L{\LB{____\* Description : Set new x and y coordinates for car object}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{private}_\K{void}_\V{setCarCoordinates}()}} \L{\LB{___\{}} \L{\LB{______\K{try}}} \L{\LB{______\{}} \L{\LB{_________\V{xPosition}_=_\V{positions}[\V{row}][\V{col}];}} \L{\LB{_________\V{yPosition}_=_\V{positions}[\V{row}][\V{col}+1];}} \L{\LB{______\}}} \L{\LB{______\K{catch}_(\V{ArrayIndexOutOfBoundsException}_\V{outOfBounds})}} \L{\LB{______\{}} \L{\LB{_________\V{parent}.\V{showStatus}(\S{}\"Out_of_Bounds!\"\SE{});}} \L{\LB{______\}}} \L{\LB{___\}}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method : setRow}} \L{\LB{____\* Return type : value of row}} \L{\LB{____\* Arguments : x and y coordinates}} \L{\LB{____\* Description : Determine the row}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{private}_\K{int}_\V{setRow}(\K{int}_\V{positionX},_\K{int}_\V{positionY})}} \L{\LB{___\{}} \L{\LB{______\K{int}_\V{newRow}_=_\V{INIT\_ROW};}} \L{\LB{______\K{int}_\V{index}_=_0;}} \L{\LB{______\K{int}_\V{startRange}_=_0,_\V{endRange}_=_0;}} \L{\LB{}} \L{\LB{______\K{if}_(\V{positionX}_==_\V{X\_DOWN})}} \L{\LB{______\{}} \L{\LB{_________\K{if}_(\V{positionY}_\>=_\V{LAST\_Y\_DOWN})}} \L{\LB{____________\V{newRow}_=_\V{LAST\_DOWN};}} \L{\LB{_________\K{else}}} \L{\LB{____________\K{while}_(\V{index}_\>=_\V{INIT\_ROW}_\&\&_\V{index}_\<_\V{LAST\_DOWN})}} \L{\LB{____________\{}} \L{\LB{_______________\V{startRange}_=_\V{positions}[\V{index}][\V{col}+1];}} \L{\LB{_______________\V{endRange}_=_\V{positions}[\V{index}+1][\V{col}+1];}} \L{\LB{_______________\K{if}_(\V{positionY}_\>=_\V{startRange}_\&\&_\V{positionY}_\<_\V{endRange})}} \L{\LB{_______________\{}} \L{\LB{__________________\V{newRow}_=_\V{index};}} \L{\LB{__________________\K{break};}} \L{\LB{_______________\}}} \L{\LB{_______________\V{index}++;}} \L{\LB{____________\}}} \L{\LB{______\}}} \L{\LB{______\K{else}_\K{if}_(\V{positionX}_==_\V{X\_UP})}} \L{\LB{______\{}} \L{\LB{_________\V{index}_=_\V{row};}} \L{\LB{_________\K{if}_(\V{positionY}_\>=_\V{FIRST\_Y\_UP})}} \L{\LB{____________\V{newRow}_=_\V{LAST\_RIGHT}_+_1;}} \L{\LB{_________\K{else}}} \L{\LB{____________\K{while}_(\V{index}_\<_\V{MAX\_ROW})}} \L{\LB{____________\{}} \L{\LB{_______________\V{startRange}_=_\V{positions}[\V{index}][\V{col}+1];}} \L{\LB{_______________\V{endRange}_=_\V{positions}[\V{index}\-1][\V{col}+1];}} \L{\LB{_______________\K{if}_(\V{positionY}_\>=_\V{startRange}_\&\&_\V{positionY}_\<_\V{endRange})}} \L{\LB{_______________\{}} \L{\LB{__________________\V{newRow}_=_\V{index};}} \L{\LB{__________________\K{break};}} \L{\LB{_______________\}}} \L{\LB{_______________\V{index}++;}} \L{\LB{____________\}}} \L{\LB{______\}}} \L{\LB{______\K{else}_\K{if}_(\V{positionY}_==_\V{Y\_RIGHT})}} \L{\LB{______\{}} \L{\LB{_________\V{index}_=_\V{row};}} \L{\LB{_________\K{if}_(\V{positionX}_\>=_\V{LAST\_X\_RIGHT})}} \L{\LB{____________\V{newRow}_=_\V{LAST\_RIGHT};}} \L{\LB{_________\K{else}}} \L{\LB{____________\K{while}_(\V{index}_\<_\V{LAST\_RIGHT})}} \L{\LB{____________\{}} \L{\LB{_______________\V{startRange}_=_\V{positions}[\V{index}][\V{col}];}} \L{\LB{_______________\V{endRange}_=_\V{positions}[\V{index}+1][\V{col}];}} \L{\LB{_______________\K{if}_(\V{positionX}_\>=_\V{startRange}_\&\&_\V{positionX}_\<_\V{endRange})}} \L{\LB{_______________\{}} \L{\LB{__________________\V{newRow}_=_\V{index};}} \L{\LB{__________________\K{break};}} \L{\LB{_______________\}}} \L{\LB{_______________\V{index}++;}} \L{\LB{____________\}}} \L{\LB{______\}}} \L{\LB{______\K{else}_\K{if}_(\V{positionY}_==_\V{COMPLETED})}} \L{\LB{______\{}} \L{\LB{_________\V{newRow}_=_\V{MAX\_ROW};}} \L{\LB{______\}}} \L{\LB{______\K{return}_\V{newRow};}} \L{\LB{___\}}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method : move}} \L{\LB{____\* Return type : void}} \L{\LB{____\* Arguments : none}} \L{\LB{____\* Description : Dictate the continous movement of a car object}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{public}_\K{void}_\V{move}()}} \L{\LB{___\{}} \L{\LB{______\K{switch}_(\V{direction})}} \L{\LB{______\{}} \L{\LB{_________\K{case}_\V{DOWN}_:}} \L{\LB{____________\V{yPosition}_+=_\V{SPEED};}} \L{\LB{____________\K{if}_(\V{yPosition}_\>=_\V{LAST\_Y\_DOWN})}} \L{\LB{____________\{}} \L{\LB{_______________\V{direction}_=_\V{RIGHT};}} \L{\LB{_______________\V{xPosition}_=_\V{positions}[4][\V{col}];}} \L{\LB{_______________\V{yPosition}_=_\V{positions}[4][\V{col}+1];}} \L{\LB{____________\}}} \L{\LB{____________\K{break};}} \L{\LB{_________\K{case}_\V{RIGHT}_:}} \L{\LB{____________\V{xPosition}_+=_\V{SPEED};}} \L{\LB{____________\K{if}_(\V{xPosition}_\>=_\V{LAST\_X\_RIGHT})}} \L{\LB{____________\{}} \L{\LB{_______________\V{direction}_=_\V{UP};}} \L{\LB{_______________\V{xPosition}_=_\V{positions}[8][\V{col}];}} \L{\LB{_______________\V{yPosition}_=_\V{positions}[8][\V{col}+1];}} \L{\LB{____________\}}} \L{\LB{____________\K{break};}} \L{\LB{_________\K{case}_\V{UP}_:}} \L{\LB{____________\V{yPosition}_\-=_\V{SPEED};}} \L{\LB{____________\K{if}_(\V{yPosition}_\<=_\V{LAST\_Y\_UP})}} \L{\LB{____________\{}} \L{\LB{_______________\V{direction}_=_\V{FINISHED};}} \L{\LB{_______________\V{xPosition}_=_\V{positions}[\V{MAX\_ROW}][\V{col}];}} \L{\LB{_______________\V{yPosition}_=_\V{positions}[\V{MAX\_ROW}][\V{col}+1];}} \L{\LB{____________\}}} \L{\LB{____________\K{break};}} \L{\LB{_________\K{case}_\V{FINISHED}_:}} \L{\LB{____________\V{direction}_=_\V{DOWN};}} \L{\LB{____________\V{xPosition}_=_\V{INIT\_X};}} \L{\LB{____________\V{yPosition}_=_\V{INIT\_Y};}} \L{\LB{____________\V{row}_=_\V{INIT\_ROW};}} \L{\LB{______\}}} \L{\LB{______\V{row}_=_\V{setRow}(\V{xPosition},_\V{yPosition});}} \L{\LB{___\}}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method : drawCar}} \L{\LB{____\* Return type : void}} \L{\LB{____\* Arguments : Graphics object to display the car in and ImageObserver}} \L{\LB{____\* for the drawImage method}} \L{\LB{____\* Description : Draw car in new position set by xPosition and yPosition}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{public}_\K{void}_\V{drawCar}(\V{Graphics}_\V{drawOn},_\V{ImageObserver}_\V{observer})}} \L{\LB{___\{}} \L{\LB{______\V{drawOn}.\V{drawImage}(\V{carImages}[\V{direction}],_\V{xPosition},_\V{yPosition},_\V{observer});}} \L{\LB{___\}}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method : showInternals}} \L{\LB{____\* Return type : void}} \L{\LB{____\* Arguments : Car object that will be displayed}} \L{\LB{____\* Description : Show the makeup of a Car object}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{public}_\K{void}_\V{showInternals}(\V{Car}_\V{carObject})}} \L{\LB{___\{}} \L{\LB{_______\V{parent}.\V{objectInfoPanel}.\V{classNameText}.\V{setText}(\V{carObject}.\V{getClass}().\V{getName}());}} \L{\LB{_______\V{parent}.\V{objectInfoPanel}.\V{inheritedClassNameText}.\V{setText}(\V{carObject}.\V{getClass}().\V{getSuperclass}().\V{getName}());}} \L{\LB{_______\V{parent}.\V{objectInfoPanel}.\V{setAttrArea}(\V{carObject}.\V{getAttributes}());}} \L{\LB{_______\V{parent}.\V{objectInfoPanel}.\V{setMethArea}(\V{carObject}.\V{getMethods}());}} \L{\LB{___\}}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method : getMethods}} \L{\LB{____\* Return type : string containing all methods of Car object}} \L{\LB{____\* Arguments : none}} \L{\LB{____\* Description : Group all methods in Car object for displaying}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{private}_\V{String}_\V{getMethods}()}} \L{\LB{___\{}} \L{\LB{______\V{StringBuffer}_\V{contained}_=_\K{new}_\V{StringBuffer}();}} \L{\LB{}} \L{\LB{______\V{contained}.\V{append}(\S{}\"Public\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"___Class_methods\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"______static_void_makeImage(CarSim_app)\2n\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"___Instance_methods\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"______Car(CarSim_parent)\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"______int_row()\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"______int_maxRow()\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"______void_startMoving()\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"______boolean_moveForward()\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"______boolean_moveBackward()\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"______void_move()\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"______void_drawCar(Graphics_drawOn,_ImageObserver_observer)\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"______void_showInternals(Car_carObject)\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"______boolean_clickedUpon(int_x,_int_y)\2n\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"Private\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"___Instance_methods\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"______int_setDirection(int_currentRow)\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"______int_setRow(int_positionX,_int_positionY)\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"______void_setCarCoordinates()\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"______String_getMethods()\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"______String_getAttributes()\2n\"\SE{});}} \L{\LB{}} \L{\LB{______\K{return}_\V{contained}.\V{toString}();}} \L{\LB{___\}}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method : getAttributes}} \L{\LB{____\* Return type : string containing all attributes of Car object}} \L{\LB{____\* Arguments : none}} \L{\LB{____\* Description : Group all attributes in Car object for displaying}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{private}_\V{String}_\V{getAttributes}()}} \L{\LB{___\{}} \L{\LB{______\V{StringBuffer}_\V{contained}_=_\K{new}_\V{StringBuffer}();}} \L{\LB{}} \L{\LB{______\V{contained}.\V{append}(\S{}\"int___xPosition\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"int___yPosition\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"int___direction\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"int___row\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"int___col\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"CarSim___parent\2n\"\SE{});}} \L{\LB{}} \L{\LB{______\K{return}_\V{contained}.\V{toString}();}} \L{\LB{___\}}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method : clickedUpon}} \L{\LB{____\* Return type : boolean - indicate the mouse position clicked is within}} \L{\LB{____\* range of this object}} \L{\LB{____\* Arguments : x and y coordinates}} \L{\LB{____\* Description : Check the coordinates are within the object\'s range}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{public}_\K{boolean}_\V{clickedUpon}(\K{int}_\V{x},_\K{int}_\V{y})}} \L{\LB{___\{}} \L{\LB{______\K{return}_((\V{x}_\>=_\V{xPosition}_\&\&_\V{x}_\<=_(\V{xPosition}_+_\V{carImages}[\V{direction}].\V{getWidth}(\V{parent})))_\&\&}} \L{\LB{______________(\V{y}_\>=_\V{yPosition}_\&\&_\V{y}_\<=_(\V{yPosition}_+_\V{carImages}[\V{direction}].\V{getHeight}(\V{parent}))));}} \L{\LB{___\}}} \L{\LB{\}}} \L{\LB{\C{}\1\* ========== Car.class ends ========== \*\1\CE{}}} \L{\LB{}} \L{\LB{\C{}\1\* ========== InformationPanel.class begins ===============================}} \L{\LB{_\*}} \L{\LB{_\* Class : InformationPanel}} \L{\LB{_\* Inherits from : Panel}} \L{\LB{_\* Description : Design the text box that is displayed in DetailsPanel}} \L{\LB{_\* Written by : Vi Huynh}} \L{\LB{_\* Creation date : 2 October 1996}} \L{\LB{_\* Last modified : 17 December 1996}} \L{\LB{_\*}} \L{\LB{_\* ======================================================================== \*\1\CE{}}} \L{\LB{\K{class}_\V{InformationPanel}_\K{extends}_\V{Panel}}} \L{\LB{\{}} \L{\LB{___\K{boolean}_\V{drawBox}_=_\K{false};}} \L{\LB{___\V{TextArea}_\V{informationArea};}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method : InformationPanel}} \L{\LB{____\* Return type : none}} \L{\LB{____\* Arguments : the value of title and boolean value to draw box}} \L{\LB{____\* Description : Constructor of InformationPanel class}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{public}_\V{InformationPanel}(\V{String}_\V{title},_\K{boolean}_\V{draw})}} \L{\LB{___\{}} \L{\LB{______\V{drawBox}_=_\V{draw};}} \L{\LB{______\V{setupPanel}(\V{title});}} \L{\LB{___\}}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method : setupPanel}} \L{\LB{____\* Return type : void}} \L{\LB{____\* Arguments : title of component}} \L{\LB{____\* Description : Construct the look of an Information Panel}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{private}_\K{void}_\V{setupPanel}(\V{String}_\V{title})}} \L{\LB{___\{}} \L{\LB{______\V{GridBagLayout}_\V{panelLayout}_=_\K{new}_\V{GridBagLayout}();}} \L{\LB{______\V{GridBagConstraints}_\V{panelConstraints}_=_\K{new}_\V{GridBagConstraints}();}} \L{\LB{______\V{setLayout}(\V{panelLayout});}} \L{\LB{______\V{setFont}(\K{new}_\V{Font}(\S{}\"TimesRoman\"\SE{},_\V{Font}.\V{PLAIN},_12));}} \L{\LB{}} \L{\LB{______\V{panelConstraints}.\V{fill}_=_\V{GridBagConstraints}.\V{NONE};}} \L{\LB{______\V{panelConstraints}.\V{anchor}_=_\V{GridBagConstraints}.\V{WEST};}} \L{\LB{______\V{panelConstraints}.\V{gridwidth}_=_\V{GridBagConstraints}.\V{REMAINDER};}} \L{\LB{______\V{Label}_\V{attributesLabel}_=_\K{new}_\V{Label}(\V{title},_\V{Label}.\V{LEFT});}} \L{\LB{______\V{attributesLabel}.\V{setFont}(\K{new}_\V{Font}(\S{}\"Helvetica\"\SE{},_\V{Font}.\V{BOLD},_14));}} \L{\LB{______\V{panelLayout}.\V{setConstraints}(\V{attributesLabel},_\V{panelConstraints});}} \L{\LB{______\V{add}(\V{attributesLabel});}} \L{\LB{}} \L{\LB{______\V{panelConstraints}.\V{fill}_=_\V{GridBagConstraints}.\V{BOTH};}} \L{\LB{______\V{informationArea}_=_\K{new}_\V{TextArea}(5,30);}} \L{\LB{______\V{panelLayout}.\V{setConstraints}(\V{informationArea},_\V{panelConstraints});}} \L{\LB{______\V{add}(\V{informationArea});}} \L{\LB{}} \L{\LB{______\V{informationArea}.\V{setEditable}(\K{false});}} \L{\LB{}} \L{\LB{______\V{validate}();}} \L{\LB{___\}}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method : insets}} \L{\LB{____\* Return type : Insets of panel object}} \L{\LB{____\* Arguments : none}} \L{\LB{____\* Description : Override Container method. Set new border size of}} \L{\LB{____\* panel}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{public}_\V{Insets}_\V{insets}()}} \L{\LB{___\{}} \L{\LB{______\K{return}_\K{new}_\V{Insets}(1,4,6,6);}} \L{\LB{___\}}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method : paint}} \L{\LB{____\* Return type : void}} \L{\LB{____\* Arguments : Graphics window to be displayed in}} \L{\LB{____\* Description : Draw a box around panel if necessary}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{public}_\K{void}_\V{paint}(\V{Graphics}_\V{output})}} \L{\LB{___\{}} \L{\LB{______\K{if}_(\V{drawBox})}} \L{\LB{______\{}} \L{\LB{_________\V{Dimension}_\V{panelDimension}_=_\V{size}();}} \L{\LB{_________\V{output}.\V{drawRect}(0,_0,_\V{panelDimension}.\V{width}_\-_2,_\V{panelDimension}.\V{height}_\-_2);}} \L{\LB{______\}}} \L{\LB{___\}}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method : appendText}} \L{\LB{____\* Return type : void}} \L{\LB{____\* Arguments : string to add in component}} \L{\LB{____\* Description : Append text at the end of informationArea component}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{public}_\K{void}_\V{appendText}(\V{String}_\V{str})}} \L{\LB{___\{}} \L{\LB{______\V{informationArea}.\V{appendText}(\V{str});}} \L{\LB{___\}}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method : setText}} \L{\LB{____\* Return type : void}} \L{\LB{____\* Arguments : string to display in component}} \L{\LB{____\* Description : Change the content of informationArea component}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{public}_\K{void}_\V{setText}(\V{String}_\V{str})}} \L{\LB{___\{}} \L{\LB{______\V{informationArea}.\V{setText}(\V{str});}} \L{\LB{___\}}} \L{\LB{\}}} \L{\LB{\C{}\1\* ========== InformationPanel.class ends ========== \*\1\CE{}}} \L{\LB{}} \L{\LB{\C{}\1\* ========== DetailsPanel.class begins ===================================}} \L{\LB{_\*}} \L{\LB{_\* Class : DetailsPanel}} \L{\LB{_\* Inherits from : Panel}} \L{\LB{_\* Description : Construct the panel to be displayed on the right-handed}} \L{\LB{_\* side of user interface. Use to display the instruction}} \L{\LB{_\* and object details.}} \L{\LB{_\* Written by : Vi Huynh}} \L{\LB{_\* Creation date : 2 October 1996}} \L{\LB{_\* Last modified : 17 December 1996}} \L{\LB{_\*}} \L{\LB{_\* ======================================================================== \*\1\CE{}}} \L{\LB{\K{class}_\V{DetailsPanel}_\K{extends}_\V{Panel}}} \L{\LB{\{}} \L{\LB{___\V{Label}_\V{classNameLabel};}} \L{\LB{___\V{Label}_\V{inheritedFromLabel};}} \L{\LB{___\V{TextField}_\V{classNameText};}} \L{\LB{___\V{TextField}_\V{inheritedClassNameText};}} \L{\LB{___\V{InformationPanel}_\V{instructPanel},_\V{attributesPanel},_\V{methodsPanel};}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method : DetailsPanel}} \L{\LB{____\* Return type : none}} \L{\LB{____\* Arguments : none}} \L{\LB{____\* Description : Constructor of DetailsPanel class}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{public}_\V{DetailsPanel}()}} \L{\LB{___\{}} \L{\LB{______\V{setupPanel}();_\C{}\1\1_ call method to initialise panel layout}} \CE{}\L{\LB{___\}}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method : setAttrArea}} \L{\LB{____\* Return type : void}} \L{\LB{____\* Arguments : string to display in component}} \L{\LB{____\* Description : Change the content of component}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{public}_\K{void}_\V{setAttrArea}(\V{String}_\V{str})}} \L{\LB{___\{}} \L{\LB{______\V{attributesPanel}.\V{setText}(\V{str});}} \L{\LB{___\}}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method : appendInstrArea}} \L{\LB{____\* Return type : void}} \L{\LB{____\* Arguments : string to be added to component}} \L{\LB{____\* Description : Append string to the end of component}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{public}_\K{void}_\V{appendInstrArea}(\V{String}_\V{str})}} \L{\LB{___\{}} \L{\LB{______\V{instructPanel}.\V{appendText}(\V{str});}} \L{\LB{___\}}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method : setInstrArea}} \L{\LB{____\* Return type : void}} \L{\LB{____\* Arguments : string to display in component}} \L{\LB{____\* Description : Change the content of attributes component}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{public}_\K{void}_\V{setInstrArea}(\V{String}_\V{str})}} \L{\LB{___\{}} \L{\LB{______\V{instructPanel}.\V{setText}(\V{str});}} \L{\LB{___\}}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method : setMethArea}} \L{\LB{____\* Return type : void}} \L{\LB{____\* Arguments : string to display in component}} \L{\LB{____\* Description : Change the content of methods component}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{public}_\K{void}_\V{setMethArea}(\V{String}_\V{str})}} \L{\LB{___\{}} \L{\LB{______\V{methodsPanel}.\V{setText}(\V{str});}} \L{\LB{___\}}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method : clearAll}} \L{\LB{____\* Return type : void}} \L{\LB{____\* Arguments : none}} \L{\LB{____\* Description : Clear components that are related to displaying object}} \L{\LB{____\* details}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{public}_\K{void}_\V{clearAll}()}} \L{\LB{___\{}} \L{\LB{______\V{classNameText}.\V{setText}(\S{}\"None\"\SE{});}} \L{\LB{______\V{inheritedClassNameText}.\V{setText}(\S{}\"None\"\SE{});}} \L{\LB{______\V{setAttrArea}(\S{}\"\"\SE{});}} \L{\LB{______\V{setMethArea}(\S{}\"\"\SE{});}} \L{\LB{___\}}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method : setupPanel}} \L{\LB{____\* Return type : void}} \L{\LB{____\* Arguments : none}} \L{\LB{____\* Description : Construct the look of DetailsPanel}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{private}_\K{void}_\V{setupPanel}()}} \L{\LB{___\{}} \L{\LB{______\C{}\1\1_ use a GridBagLayout layout manager to position components}} \CE{}\L{\LB{______\V{GridBagLayout}_\V{detailsLayout}_=_\K{new}_\V{GridBagLayout}();}} \L{\LB{______\V{GridBagConstraints}_\V{detailsConstraints}_=_\K{new}_\V{GridBagConstraints}();}} \L{\LB{______\V{setLayout}(\V{detailsLayout});}} \L{\LB{}} \L{\LB{______\C{}\1\1_ stretch component horizontally if resize}} \CE{}\L{\LB{______\V{detailsConstraints}.\V{fill}_=_\V{GridBagConstraints}.\V{HORIZONTAL};}} \L{\LB{______\C{}\1\1_ use the whole row}} \CE{}\L{\LB{______\V{detailsConstraints}.\V{gridwidth}_=_\V{GridBagConstraints}.\V{REMAINDER};}} \L{\LB{______\V{instructPanel}_=_\K{new}_\V{InformationPanel}(\S{}\"Instructions\"\SE{},_\K{false});}} \L{\LB{______\V{detailsLayout}.\V{setConstraints}(\V{instructPanel},_\V{detailsConstraints});}} \L{\LB{______\V{add}(\V{instructPanel});_\C{}\1\1_ add to panel component}} \CE{}\L{\LB{}} \L{\LB{______\C{}\1\1_ no stretching for following components}} \CE{}\L{\LB{______\V{detailsConstraints}.\V{fill}_=_\V{GridBagConstraints}.\V{NONE};}} \L{\LB{______\V{classNameLabel}_=_\K{new}_\V{Label}(\S{}\"Class_:\"\SE{},_\V{Label}.\V{LEFT});}} \L{\LB{______\V{classNameLabel}.\V{setFont}(\K{new}_\V{Font}(\S{}\"Helvetica\"\SE{},_\V{Font}.\V{BOLD},_14));}} \L{\LB{______\V{detailsConstraints}.\V{anchor}_=_\V{GridBagConstraints}.\V{NORTHWEST};_\C{}\1\1_ placement}} \CE{}\L{\LB{______\C{}\1\1_ width of grid is relative to the last component}} \CE{}\L{\LB{______\V{detailsConstraints}.\V{gridwidth}_=_\V{GridBagConstraints}.\V{RELATIVE};}} \L{\LB{______\V{detailsLayout}.\V{setConstraints}(\V{classNameLabel},_\V{detailsConstraints});}} \L{\LB{______\V{add}(\V{classNameLabel});}} \L{\LB{______\V{classNameText}_=_\K{new}_\V{TextField}(\S{}\"None\"\SE{},_11);}} \L{\LB{______\V{classNameText}.\V{setFont}(\K{new}_\V{Font}(\S{}\"TimesRoman\"\SE{},_\V{Font}.\V{PLAIN},_12));}} \L{\LB{______\V{classNameText}.\V{setBackground}(\V{Color}.\V{gray});}} \L{\LB{______\V{detailsConstraints}.\V{anchor}_=_\V{GridBagConstraints}.\V{WEST};}} \L{\LB{______\C{}\1\1_ last component on row - classNameText}} \CE{}\L{\LB{______\V{detailsConstraints}.\V{gridwidth}_=_\V{GridBagConstraints}.\V{REMAINDER};}} \L{\LB{______\V{detailsLayout}.\V{setConstraints}(\V{classNameText},_\V{detailsConstraints});}} \L{\LB{______\V{add}(\V{classNameText});}} \L{\LB{______\V{classNameText}.\V{setEditable}(\K{false});_\C{}\1\1_ no modification to component}} \CE{}\L{\LB{}} \L{\LB{______\V{inheritedFromLabel}_=_\K{new}_\V{Label}(\S{}\"Inherited_From_:\"\SE{},_\V{Label}.\V{LEFT});}} \L{\LB{______\V{inheritedFromLabel}.\V{setFont}(\K{new}_\V{Font}(\S{}\"Helvetica\"\SE{},_\V{Font}.\V{BOLD},_14));}} \L{\LB{______\V{detailsConstraints}.\V{anchor}_=_\V{GridBagConstraints}.\V{EAST};}} \L{\LB{______\V{detailsConstraints}.\V{gridwidth}_=_\V{GridBagConstraints}.\V{RELATIVE};}} \L{\LB{______\V{detailsLayout}.\V{setConstraints}(\V{inheritedFromLabel},_\V{detailsConstraints});}} \L{\LB{______\V{add}(\V{inheritedFromLabel});}} \L{\LB{______\V{inheritedClassNameText}_=_\K{new}_\V{TextField}(\S{}\"None\"\SE{},_11);}} \L{\LB{______\V{inheritedClassNameText}.\V{setFont}(\K{new}_\V{Font}(\S{}\"TimesRoman\"\SE{},_\V{Font}.\V{PLAIN},_12));}} \L{\LB{______\V{inheritedClassNameText}.\V{setBackground}(\V{Color}.\V{gray});}} \L{\LB{______\V{detailsConstraints}.\V{anchor}_=_\V{GridBagConstraints}.\V{WEST};}} \L{\LB{______\V{detailsConstraints}.\V{gridwidth}_=_\V{GridBagConstraints}.\V{REMAINDER};}} \L{\LB{______\V{detailsLayout}.\V{setConstraints}(\V{inheritedClassNameText},_\V{detailsConstraints});}} \L{\LB{______\V{add}(\V{inheritedClassNameText});}} \L{\LB{______\V{inheritedClassNameText}.\V{setEditable}(\K{false});}} \L{\LB{}} \L{\LB{______\V{detailsConstraints}.\V{fill}_=_\V{GridBagConstraints}.\V{HORIZONTAL};}} \L{\LB{______\V{attributesPanel}_=_\K{new}_\V{InformationPanel}(\S{}\"Attributes\"\SE{},_\K{true});}} \L{\LB{______\V{detailsConstraints}.\V{gridwidth}_=_\V{GridBagConstraints}.\V{REMAINDER};}} \L{\LB{______\V{detailsLayout}.\V{setConstraints}(\V{attributesPanel},_\V{detailsConstraints});}} \L{\LB{______\V{add}(\V{attributesPanel});}} \L{\LB{}} \L{\LB{______\V{methodsPanel}_=_\K{new}_\V{InformationPanel}(\S{}\"Methods\"\SE{},_\K{true});}} \L{\LB{______\V{detailsLayout}.\V{setConstraints}(\V{methodsPanel},_\V{detailsConstraints});}} \L{\LB{______\V{add}(\V{methodsPanel});}} \L{\LB{}} \L{\LB{______\V{validate}();}} \L{\LB{___\}}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method : insets}} \L{\LB{____\* Return type : Insets of panel object}} \L{\LB{____\* Arguments : none}} \L{\LB{____\* Description : Override Container method. Set new border size of}} \L{\LB{____\* panel}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{public}_\V{Insets}_\V{insets}()}} \L{\LB{___\{}} \L{\LB{______\K{return}_\K{new}_\V{Insets}(5,5,4,4);}} \L{\LB{___\}}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method : paint}} \L{\LB{____\* Return type : void}} \L{\LB{____\* Arguments : Graphics window that will display the panel}} \L{\LB{____\* Description : Override Component method. Draw a box around panel}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{public}_\K{void}_\V{paint}(\V{Graphics}_\V{output})}} \L{\LB{___\{}} \L{\LB{______\V{Dimension}_\V{panelDimension}_=_\V{size}();}} \L{\LB{______\V{output}.\V{drawRect}(0,_0,_\V{panelDimension}.\V{width}_\-_1,_\V{panelDimension}.\V{height}_\-_1);}} \L{\LB{___\}}} \L{\LB{\}}} \L{\LB{\C{}\1\* ========== DetailsPanel.class ends ========== \*\1\CE{}}} \L{\LB{}} \L{\LB{\C{}\1\* ========== CarManufacturingComponent.class begins =====================================}} \L{\LB{_\*}} \L{\LB{_\* Class : CarManufacturingComponent}} \L{\LB{_\* Inherits from : Object}} \L{\LB{_\* Description : The base class of all manufacturing components.}} \L{\LB{_\* Written by : Vi Huynh}} \L{\LB{_\* Creation date : 15 December 1996}} \L{\LB{_\* Last modified : 17 December 1996}} \L{\LB{_\*}} \L{\LB{_\* ======================================================================== \*\1\CE{}}} \L{\LB{\K{abstract}_\K{class}_\V{CarManufacturingComponent}_\K{extends}_\V{Object}}} \L{\LB{\{}} \L{\LB{___\C{}\1\1_ instance variables}} \CE{}\L{\LB{___\V{CarSim}_\V{app};}} \L{\LB{___\K{int}_\V{topLeftX},_\V{topLeftY},_\V{bottomRightX},_\V{bottomRightY};}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method : getAttributes}} \L{\LB{____\* Return type : void}} \L{\LB{____\* Arguments : none}} \L{\LB{____\* Description : abstract method. Implmentation provided by subclassing}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{private}_\K{abstract}_\V{String}_\V{getAttributes}();}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method : getMethods}} \L{\LB{____\* Return type : void}} \L{\LB{____\* Arguments : none}} \L{\LB{____\* Description : abstract method. Implmentation provided by subclassing}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{private}_\K{abstract}_\V{String}_\V{getMethods}();}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method : clickedUpon}} \L{\LB{____\* Return type : boolean value that object is in range}} \L{\LB{____\* Arguments : x and y coordinates}} \L{\LB{____\* Description : Determine the click position is within range of the object}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{public}_\K{boolean}_\V{clickedUpon}(\K{int}_\V{x},_\K{int}_\V{y})}} \L{\LB{___\{}} \L{\LB{_______\K{return}_\V{x}_\>=_\V{topLeftX}_\&\&_\V{x}_\<=_\V{bottomRightX}_\&\&_\V{y}_\>=_\V{topLeftY}_\&\&_\V{y}_\<=_\V{bottomRightY};}} \L{\LB{___\}}} \L{\LB{\}}} \L{\LB{\C{}\1\* ========== CarManufacturingComponent.class ends ========== \*\1\CE{}}} \L{\LB{}} \L{\LB{\C{}\1\* ========== StackTower.class begins =====================================}} \L{\LB{_\*}} \L{\LB{_\* Class : StackTower}} \L{\LB{_\* Inherits from : CarManufacturingComponent}} \L{\LB{_\* Description : One of the makeup classes for user interaction. Provide}} \L{\LB{_\* the placement of stored cars that is displayed}} \L{\LB{_\* Written by : Vi Huynh}} \L{\LB{_\* Creation date : 15 December 1996}} \L{\LB{_\* Last modified : 17 December 1996}} \L{\LB{_\*}} \L{\LB{_\* ======================================================================== \*\1\CE{}}} \L{\LB{\K{class}_\V{StackTower}_\K{extends}_\V{CarManufacturingComponent}}} \L{\LB{\{}} \L{\LB{___\C{}\1\1_ instance variables}} \CE{}\L{\LB{___\K{int}_\V{numberOfCars};}} \L{\LB{___\K{int}_\V{numberOfLevels};}} \L{\LB{___\K{int}_\V{maximumCapacity};}} \L{\LB{___\V{Vector}_\V{carsStored};}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method : StackTower}} \L{\LB{____\* Return type : none}} \L{\LB{____\* Arguments : CarSim ojbect to be referenced and a Vector of car objects}} \L{\LB{____\* Description : Constructor of StackTower class}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{public}_\V{StackTower}(\V{CarSim}_\V{app},_\V{Vector}_\V{cars})}} \L{\LB{___\{}} \L{\LB{______\C{}\1\1_ initialise variables}} \CE{}\L{\LB{______\K{this}.\V{app}_=_\V{app};}} \L{\LB{______\V{carsStored}_=_\K{new}_\V{Vector}();}} \L{\LB{______\V{carsStored}_=_\V{cars};}} \L{\LB{______\V{numberOfCars}_=_\V{carsStored}.\V{size}();}} \L{\LB{______\V{numberOfLevels}_=_4;}} \L{\LB{______\V{maximumCapacity}_=_100;}} \L{\LB{}} \L{\LB{______\C{}\1\1_ object size}} \CE{}\L{\LB{______\V{topLeftX}_=_121;}} \L{\LB{______\V{topLeftY}_=_0;}} \L{\LB{______\V{bottomRightX}_=_192;}} \L{\LB{______\V{bottomRightY}_=_47;}} \L{\LB{___\}}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method : getCar}} \L{\LB{____\* Return type : Car object from stack tower}} \L{\LB{____\* Arguments : none}} \L{\LB{____\* Description : Retrieve a Car object from stack tower if there are cars}} \L{\LB{____\* in tower}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{public}_\V{Car}_\V{getCar}()}} \L{\LB{___\{}} \L{\LB{______\K{if}_(\V{numberOfCars}_!=_0)}} \L{\LB{______\{}} \L{\LB{_________\V{Car}_\V{retrievedCar}_=_(\V{Car})_\V{carsStored}.\V{firstElement}();}} \L{\LB{_________\V{carsStored}.\V{removeElement}(\V{retrievedCar});}} \L{\LB{_________\V{numberOfCars}_=_\V{updateCarStored}();}} \L{\LB{_________\K{return}_\V{retrievedCar};}} \L{\LB{______\}}} \L{\LB{}} \L{\LB{______\K{return}_\K{null};}} \L{\LB{___\}}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method : updateCarStored}} \L{\LB{____\* Return type : current number of cars stored}} \L{\LB{____\* Arguments : none}} \L{\LB{____\* Description : Get number of cars stored in stack tower}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{private}_\K{int}_\V{updateCarStored}()}} \L{\LB{___\{}} \L{\LB{______\K{return}_\V{carsStored}.\V{size}();}} \L{\LB{___\}}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method : carExist}} \L{\LB{____\* Return type : boolean - indicate the car exist}} \L{\LB{____\* Arguments : Car object that will be compared}} \L{\LB{____\* Description : Check the car object is stored in stack tower}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{public}_\K{boolean}_\V{carExist}(\V{Car}_\V{aCar})}} \L{\LB{___\{}} \L{\LB{_______\K{return}_\V{carsStored}.\V{contains}(\V{aCar});}} \L{\LB{___\}}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method : canAddCars}} \L{\LB{____\* Return type : boolean - indicate stack tower can add more cars}} \L{\LB{____\* Arguments : none}} \L{\LB{____\* Description : Check if the more cars can be added to the stack tower}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{public}_\K{boolean}_\V{canAddCars}()}} \L{\LB{___\{}} \L{\LB{______\K{return}_\V{carsStored}.\V{size}()_\<_\V{capacity}();}} \L{\LB{___\}}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method : capacity}} \L{\LB{____\* Return type : value of maximumCapacity}} \L{\LB{____\* Arguments : none}} \L{\LB{____\* Description : Get value of maximumCapacity}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{public}_\K{int}_\V{capacity}()}} \L{\LB{___\{}} \L{\LB{______\K{return}_\V{maximumCapacity};}} \L{\LB{___\}}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method : showInternals}} \L{\LB{____\* Return type : void}} \L{\LB{____\* Arguments : StackTower objec that will be displayed}} \L{\LB{____\* Description : Show the makeup of a StackTower object}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{public}_\K{void}_\V{showInternals}(\V{StackTower}_\V{aStackTower})}} \L{\LB{___\{}} \L{\LB{______\V{app}.\V{objectInfoPanel}.\V{classNameText}.\V{setText}(\V{aStackTower}.\V{getClass}().\V{getName}());}} \L{\LB{______\V{app}.\V{objectInfoPanel}.\V{inheritedClassNameText}.\V{setText}(\V{aStackTower}.\V{getClass}().\V{getSuperclass}().\V{getName}());}} \L{\LB{______\V{app}.\V{objectInfoPanel}.\V{setAttrArea}(\V{aStackTower}.\V{getAttributes}());}} \L{\LB{______\V{app}.\V{objectInfoPanel}.\V{setMethArea}(\V{aStackTower}.\V{getMethods}());}} \L{\LB{___\}}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method : getAttributes}} \L{\LB{____\* Return type : string containing all attributes in StackTower object}} \L{\LB{____\* Arguments : none}} \L{\LB{____\* Description : Override CarManufacturingComponent method. Group all}} \L{\LB{____\* attributes in StackTower object for displaying}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{private}_\V{String}_\V{getAttributes}()}} \L{\LB{___\{}} \L{\LB{______\V{StringBuffer}_\V{contained}_=_\K{new}_\V{StringBuffer}();}} \L{\LB{}} \L{\LB{______\V{contained}.\V{append}(\S{}\"int___numberOfCars\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"int___numberOfLevels\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"int___maximumCapacity\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"Vector_carsStored\2n\"\SE{});}} \L{\LB{}} \L{\LB{______\K{return}_\V{contained}.\V{toString}();}} \L{\LB{___\}}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method : getMethods}} \L{\LB{____\* Return type : string containing all methods in StackTower object}} \L{\LB{____\* Arguments : none}} \L{\LB{____\* Description : Override CarManufacturingComponent method. Group all}} \L{\LB{____\* methods in StackTower objec for displaying}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{private}_\V{String}_\V{getMethods}()}} \L{\LB{___\{}} \L{\LB{______\V{StringBuffer}_\V{contained}_=_\K{new}_\V{StringBuffer}();}} \L{\LB{}} \L{\LB{______\V{contained}.\V{append}(\S{}\"Public\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"___Instance_methods\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"______StackTower(CarSim_app,_Vector_cars)\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"______Car_getCar()\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"______boolean_carExist(Car_aCar)\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"______boolean_canAddCars()\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"______int_capacity()\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"______void_showInternals(StackTower_aStackTower)\2n\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"Private\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"___Instance_methods\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"______int_updateCarStored()\2n\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"___Overriden_methods\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"______String_getAttributes()\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"______String_getMethods()\2n\"\SE{});}} \L{\LB{}} \L{\LB{______\K{return}_\V{contained}.\V{toString}();}} \L{\LB{___\}}} \L{\LB{\}}} \L{\LB{\C{}\1\* ========== StackTower.class ends ========== \*\1\CE{}}} \L{\LB{}} \L{\LB{\C{}\1\* ========== FrontModule.class begins ====================================}} \L{\LB{_\*}} \L{\LB{_\* Class : FrontModule}} \L{\LB{_\* Inherits from : CarManufacturingComponent}} \L{\LB{_\* Description : One of the assembly line module. A makeup class for user}} \L{\LB{_\* interaction}} \L{\LB{_\* Written by : Vi Huynh}} \L{\LB{_\* Creation date : 15 December 1996}} \L{\LB{_\* Last modified : 17 December 1996}} \L{\LB{_\*}} \L{\LB{_\* ======================================================================== \*\1\CE{}}} \L{\LB{\K{class}_\V{FrontModule}_\K{extends}_\V{CarManufacturingComponent}}} \L{\LB{\{}} \L{\LB{___\C{}\1\1_ instance variable}} \CE{}\L{\LB{___\K{int}_\V{numberOfFittingComponents};}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method : FrontModule}} \L{\LB{____\* Return type : none}} \L{\LB{____\* Arguments : CarSim objec that will be referenced for use in current}} \L{\LB{____\* class}} \L{\LB{____\* Description : Constructor of FrontModule class}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{public}_\V{FrontModule}(\V{CarSim}_\V{app})}} \L{\LB{___\{}} \L{\LB{______\K{this}.\V{app}_=_\V{app};}} \L{\LB{______\V{numberOfFittingComponents}_=_3;}} \L{\LB{______\V{topLeftX}_=_151;}} \L{\LB{______\V{topLeftY}_=_331;}} \L{\LB{______\V{bottomRightX}_=_201;}} \L{\LB{______\V{bottomRightY}_=_434;}} \L{\LB{___\}}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method : assembleModule}} \L{\LB{____\* Return type : void}} \L{\LB{____\* Arguments : a CoolerComponent object and LightsComponent object that}} \L{\LB{____\* will start component assembling}} \L{\LB{____\* Description : Makeup method that start the assembling of a cooler and}} \L{\LB{____\* lights to the car}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{public}_\K{void}_\V{assembleModule}(\V{CoolerComponent}_\V{aCooler},_\V{LightsComponent}_\V{aLights})}} \L{\LB{___\{}} \L{\LB{______\V{aCooler}.\V{beginCoolerAssembling}();}} \L{\LB{______\V{aLights}.\V{beginLightsAssembling}();}} \L{\LB{______\V{app}.\V{getAppletContext}().\V{showStatus}(\S{}\"Fitting_COOLER_and_LIGHTS_to_the_car.\,.\,.\"\SE{});}} \L{\LB{___\}}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method : showInternals}} \L{\LB{____\* Return type : void}} \L{\LB{____\* Arguments : FrontModule object that will be displayed}} \L{\LB{____\* Description : Show the makeup of a FrontModule object}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{public}_\K{void}_\V{showInternals}(\V{FrontModule}_\V{frontModule})}} \L{\LB{___\{}} \L{\LB{______\V{app}.\V{objectInfoPanel}.\V{classNameText}.\V{setText}(\V{frontModule}.\V{getClass}().\V{getName}());}} \L{\LB{______\V{app}.\V{objectInfoPanel}.\V{inheritedClassNameText}.\V{setText}(\V{frontModule}.\V{getClass}().\V{getSuperclass}().\V{getName}());}} \L{\LB{______\V{app}.\V{objectInfoPanel}.\V{setAttrArea}(\V{frontModule}.\V{getAttributes}());}} \L{\LB{______\V{app}.\V{objectInfoPanel}.\V{setMethArea}(\V{frontModule}.\V{getMethods}());}} \L{\LB{___\}}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method : getAttributes}} \L{\LB{____\* Return type : string containing all attributes in a FrontModule object}} \L{\LB{____\* Arguments : none}} \L{\LB{____\* Description : Override CarManufacturingComponent method. Group all}} \L{\LB{____\* attributes that belong to a FrontModule object}} \L{\LB{____\* for displaying}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{private}_\V{String}_\V{getAttributes}()}} \L{\LB{___\{}} \L{\LB{______\V{StringBuffer}_\V{contained}_=_\K{new}_\V{StringBuffer}();}} \L{\LB{______\V{contained}.\V{append}(\S{}\"int___numberOfFittingComponents\2n\"\SE{});}} \L{\LB{}} \L{\LB{______\K{return}_\V{contained}.\V{toString}();}} \L{\LB{___\}}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method : getMethods}} \L{\LB{____\* Return type : string containing all methods to a FrontModule object}} \L{\LB{____\* Arguments : none}} \L{\LB{____\* Description : Override CarManufacturingComponent method. Group all}} \L{\LB{____\* methods that belong to a FrontModule object for}} \L{\LB{____\* displaying}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{private}_\V{String}_\V{getMethods}()}} \L{\LB{___\{}} \L{\LB{______\V{StringBuffer}_\V{contained}_=_\K{new}_\V{StringBuffer}();}} \L{\LB{}} \L{\LB{______\V{contained}.\V{append}(\S{}\"Public\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"___Instance_methods\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"______FrontModule(CarSim_app)\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"______void_assembleModule(CoolerComponent_aCooler,_LightsComponent_aLights)\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"______void_showInternals(FrontModule_frontModule)\2n\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"Private\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"___Instance_methods\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"______String_getAttributes()\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"______String_getMethods()\2n\"\SE{});}} \L{\LB{}} \L{\LB{______\K{return}_\V{contained}.\V{toString}();}} \L{\LB{___\}}} \L{\LB{\}}} \L{\LB{\C{}\1\* ========== FrontModule.class ends ========== \*\1\CE{}}} \L{\LB{}} \L{\LB{\C{}\1\* ========== AssemblyLineComponent.class begins ==========================}} \L{\LB{_\*}} \L{\LB{_\* Class : AssemblyLineComponent}} \L{\LB{_\* Inherits from : CarManufacturingComponent}} \L{\LB{_\* Description : The base class to all assembly line components.}} \L{\LB{_\* Written by : Vi Huynh}} \L{\LB{_\* Creation date : 15 December 1996}} \L{\LB{_\* Last modified : 17 December 1996}} \L{\LB{_\*}} \L{\LB{_\* ======================================================================== \*\1\CE{}}} \L{\LB{\K{abstract}_\K{class}_\V{AssemblyLineComponent}_\K{extends}_\V{CarManufacturingComponent}}} \L{\LB{\{}} \L{\LB{___\C{}\1\1_ instance variables}} \CE{}\L{\LB{___\K{int}_\V{numberOfWorkers};}} \L{\LB{___\K{int}_\V{numberOfInventory};}} \L{\LB{___\K{boolean}_\V{putInOrder};}} \L{\LB{___\K{int}_\V{reorderingLimit};}} \L{\LB{}} \L{\LB{____\C{}\1\*}} \L{\LB{_____\* Method : performStocktaking}} \L{\LB{_____\* Return type : void}} \L{\LB{_____\* Arguments : none}} \L{\LB{_____\* Description : abstract method. Implmentation provided by subclassing}} \L{\LB{_____\*\1\CE{}}} \L{\LB{____\K{public}_\K{abstract}_\K{void}_\V{performStocktaking}();}} \L{\LB{}} \L{\LB{\}}} \L{\LB{\C{}\1\* ========== AssemblyLineComponent.class ends ========== \*\1\CE{}}} \L{\LB{}} \L{\LB{\C{}\1\* ========== CarWindowsComponent.class begins ============================}} \L{\LB{_\*}} \L{\LB{_\* Class : CarWindowsComponent}} \L{\LB{_\* Inherits from : AssemblyLineComponent}} \L{\LB{_\* Description : A makeup class for user interaction.}} \L{\LB{_\* Written by : Vi Huynh}} \L{\LB{_\* Creation date : 15 December 1996}} \L{\LB{_\* Last modified : 17 December 1996}} \L{\LB{_\*}} \L{\LB{_\* ======================================================================== \*\1\CE{}}} \L{\LB{\K{class}_\V{CarWindowsComponent}_\K{extends}_\V{AssemblyLineComponent}}} \L{\LB{\{}} \L{\LB{___\K{int}_\V{numberOfWindowsUsed};}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method : CarWindowsComponent}} \L{\LB{____\* Return type : none}} \L{\LB{____\* Arguments : a reference to CarSim object}} \L{\LB{____\* Description : Constructor of CarWindowsComponent class}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{public}_\V{CarWindowsComponent}(\V{CarSim}_\V{app})}} \L{\LB{___\{}} \L{\LB{______\C{}\1\1_ initialise variables}} \CE{}\L{\LB{______\K{this}.\V{app}_=_\V{app};}} \L{\LB{______\V{numberOfWorkers}_=_6;}} \L{\LB{______\V{numberOfInventory}_=_20;}} \L{\LB{______\V{numberOfWindowsUsed}_=_0;}} \L{\LB{______\V{putInOrder}_=_\K{false};}} \L{\LB{______\V{reorderingLimit}_=_10;}} \L{\LB{}} \L{\LB{______\C{}\1\1_ component range}} \CE{}\L{\LB{______\V{topLeftX}_=_166;}} \L{\LB{______\V{topLeftY}_=_119;}} \L{\LB{______\V{bottomRightX}_=_239;}} \L{\LB{______\V{bottomRightY}_=_153;}} \L{\LB{___\}}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method : beginWindowsAssembling}} \L{\LB{____\* Return type : boolean - indicate component assembling completed}} \L{\LB{____\* Arguments : none}} \L{\LB{____\* Description : Makeup method that show the assembled component is}} \L{\LB{____\* assembling.}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{public}_\K{boolean}_\V{beginWindowsAssembling}()}} \L{\LB{___\{}} \L{\LB{______\K{if}_(\V{putInOrder})}} \L{\LB{______\{}} \L{\LB{_________\K{int}_\V{newInventory}_=_50;______________\C{}\1\1_ arbitrarily enhanced inventory}} \CE{}\L{\LB{_________\V{numberOfInventory}_+=_\V{newInventory};__\C{}\1\1_ level}} \CE{}\L{\LB{_________\V{putInOrder}_=_\K{false};}} \L{\LB{______\}}} \L{\LB{______\K{if}_(\V{assembleWindscreen}())}} \L{\LB{______\{}} \L{\LB{_________\V{app}.\V{getAppletContext}().\V{showStatus}(\S{}\"Fitting_WINDOWS_to_the_car.\,.\,.\"\SE{});}} \L{\LB{_________\K{if}_(\V{assembleSideWindows}())}} \L{\LB{____________\V{assembleRearWindow}();}} \L{\LB{______\}}} \L{\LB{______\V{performStocktaking}();}} \L{\LB{______\K{return}_\K{true};}} \L{\LB{___\}}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method : assembleWindscreen}} \L{\LB{____\* Return type : boolean - indicate completion of windscreen assembling}} \L{\LB{____\* Arguments : none}} \L{\LB{____\* Description : Makeup method that show the assembling of a windscreen}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{private}_\K{boolean}_\V{assembleWindscreen}()}} \L{\LB{___\{}} \L{\LB{______\V{numberOfWindowsUsed}_+=_1;}} \L{\LB{______\K{return}_\K{true};}} \L{\LB{___\}}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method : assembleSideWindows}} \L{\LB{____\* Return type : boolean - indicate side windows assembling is completed}} \L{\LB{____\* Arguments : none}} \L{\LB{____\* Description : Makeup method that show the assembling of side windows.}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{private}_\K{boolean}_\V{assembleSideWindows}()}} \L{\LB{___\{}} \L{\LB{______\V{numberOfWindowsUsed}_+=_4;}} \L{\LB{______\K{return}_\K{true};}} \L{\LB{___\}}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method : assembleRearWindow}} \L{\LB{____\* Return type : boolean - indicate rear window assembling is completed}} \L{\LB{____\* Arguments : none}} \L{\LB{____\* Description : Makeup method that show the assembling of rear window}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{private}_\K{boolean}_\V{assembleRearWindow}()}} \L{\LB{___\{}} \L{\LB{______\V{numberOfWindowsUsed}_+=_1;}} \L{\LB{______\K{return}_\K{true};}} \L{\LB{___\}}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method : performStocktaking}} \L{\LB{____\* Return type : void}} \L{\LB{____\* Arguments : none}} \L{\LB{____\* Description : Override AssemblyLineComponent method. Check the level}} \L{\LB{____\* of window stocks and put in order if low on stock.}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{public}_\K{void}_\V{performStocktaking}()}} \L{\LB{___\{}} \L{\LB{______\V{numberOfInventory}_\-=_\V{numberOfWindowsUsed};}} \L{\LB{______\K{if}_(\V{numberOfInventory}_\<=_\V{reorderingLimit})}} \L{\LB{______\{}} \L{\LB{_________\V{putInOrder}_=_\K{true};}} \L{\LB{______\}}} \L{\LB{___\}}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method : showInternals}} \L{\LB{____\* Return type : void}} \L{\LB{____\* Arguments : a CarWindowsComponent object that will be displayed}} \L{\LB{____\* Description : Show information on the car window object}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{public}_\K{void}_\V{showInternals}(\V{CarWindowsComponent}_\V{aCarWindows})}} \L{\LB{___\{}} \L{\LB{______\V{app}.\V{objectInfoPanel}.\V{classNameText}.\V{setText}(\V{aCarWindows}.\V{getClass}().\V{getName}());}} \L{\LB{______\V{app}.\V{objectInfoPanel}.\V{inheritedClassNameText}.\V{setText}(\V{aCarWindows}.\V{getClass}().\V{getSuperclass}().\V{getName}());}} \L{\LB{______\V{app}.\V{objectInfoPanel}.\V{setAttrArea}(\V{aCarWindows}.\V{getAttributes}());}} \L{\LB{______\V{app}.\V{objectInfoPanel}.\V{setMethArea}(\V{aCarWindows}.\V{getMethods}());}} \L{\LB{___\}}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method : getAttributes}} \L{\LB{____\* Return type : string containing all the attributes of object}} \L{\LB{____\* Arguments : none}} \L{\LB{____\* Description : Override CarManufacturingComponent method. Group all}} \L{\LB{____\* attributes in CarWindowsComponent object for displaying.}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{private}_\V{String}_\V{getAttributes}()}} \L{\LB{___\{}} \L{\LB{______\V{StringBuffer}_\V{contained}_=_\K{new}_\V{StringBuffer}();}} \L{\LB{}} \L{\LB{______\V{contained}.\V{append}(\S{}\"int___numberOfWindowsUsed\2n\"\SE{});}} \L{\LB{}} \L{\LB{______\K{return}_\V{contained}.\V{toString}();}} \L{\LB{___\}}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method : getMethods}} \L{\LB{____\* Return type : string containing all the methods of object}} \L{\LB{____\* Arguments : none}} \L{\LB{____\* Description : Ovveride CarManufacturingComponent method. Group all methods}} \L{\LB{____\* belonging to CarWindowsComponent object for displaying.}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{private}_\V{String}_\V{getMethods}()}} \L{\LB{___\{}} \L{\LB{______\V{StringBuffer}_\V{contained}_=_\K{new}_\V{StringBuffer}();}} \L{\LB{}} \L{\LB{______\V{contained}.\V{append}(\S{}\"Public\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"___Instance_methods\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"______CarWindowsComponent(CarSim_app)\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"______boolean_beginWindowsAssembling()\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"______void_showInternals(CarWindowsComponent_aCarWindows)\2n\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"___Overridden_methods\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"______void_performStocktaking()\2n\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"Private\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"___Instance_methods\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"______boolean_assembleWindscreen()\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"______boolean_assembleSideWindows()\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"______boolean_assembleRearWindow()\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"___Overridden_methods\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"______String_getAttributes()\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"______String_getMethods()\2n\2n\"\SE{});}} \L{\LB{}} \L{\LB{______\K{return}_\V{contained}.\V{toString}();}} \L{\LB{___\}}} \L{\LB{\}}} \L{\LB{\C{}\1\* ========== CarWindowsComponent.class ends ========== \*\1\CE{}}} \L{\LB{}} \L{\LB{\C{}\1\* ========== CoolerComponent.class begins ===============================}} \L{\LB{_\*}} \L{\LB{_\* Class : CoolerComponent}} \L{\LB{_\* Inherits from : AssemblyLineComponent}} \L{\LB{_\* Description : A makeup class for user interaction.}} \L{\LB{_\* Written by : Vi Huynh}} \L{\LB{_\* Creation date : 15 December 1996}} \L{\LB{_\* Last modified : 17 December 1996}} \L{\LB{_\*}} \L{\LB{_\* ======================================================================== \*\1\CE{}}} \L{\LB{\K{class}_\V{CoolerComponent}_\K{extends}_\V{AssemblyLineComponent}}} \L{\LB{\{}} \L{\LB{___\K{int}_\V{numberOfCoolersUsed};}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method : CoolerComponent}} \L{\LB{____\* Return type : none}} \L{\LB{____\* Arguments : a reference to CarSim object}} \L{\LB{____\* Description : Constructor to CoolerComponent class}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{public}_\V{CoolerComponent}(\V{CarSim}_\V{app})}} \L{\LB{___\{}} \L{\LB{______\C{}\1\1_ initialise variables}} \CE{}\L{\LB{______\K{this}.\V{app}_=_\V{app};}} \L{\LB{______\V{numberOfWorkers}_=_2;}} \L{\LB{______\V{numberOfInventory}_=_5;}} \L{\LB{______\V{numberOfCoolersUsed}_=_0;}} \L{\LB{______\V{putInOrder}_=_\K{false};}} \L{\LB{______\V{reorderingLimit}_=_3;}} \L{\LB{}} \L{\LB{______\C{}\1\1_ size of object}} \CE{}\L{\LB{______\V{topLeftX}_=_102;}} \L{\LB{______\V{topLeftY}_=_348;}} \L{\LB{______\V{bottomRightX}_=_151;}} \L{\LB{______\V{bottomRightY}_=_385;}} \L{\LB{___\}}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method : beginCoolerAssembling}} \L{\LB{____\* Return type : boolean - indicate the completion of cooler assembling}} \L{\LB{____\* Arguments : none}} \L{\LB{____\* Description : Makeup method that show the assembling of a cooler to a}} \L{\LB{____\* car}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{public}_\K{boolean}_\V{beginCoolerAssembling}()}} \L{\LB{___\{}} \L{\LB{______\K{if}_(\V{putInOrder})}} \L{\LB{______\{}} \L{\LB{_________\K{int}_\V{newInventory}_=_5;______________\C{}\1\1_ arbitrarily enhanced inventory}} \CE{}\L{\LB{_________\V{numberOfInventory}_+=_\V{newInventory};__\C{}\1\1_ level}} \CE{}\L{\LB{_________\V{putInOrder}_=_\K{false};}} \L{\LB{______\}}} \L{\LB{______\V{numberOfCoolersUsed}_+=_1;}} \L{\LB{______\V{performStocktaking}();}} \L{\LB{______\K{return}_\K{true};}} \L{\LB{___\}}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method : performStocktaking}} \L{\LB{____\* Return type : void}} \L{\LB{____\* Arguments : none}} \L{\LB{____\* Description : Override AssemblyLineComponent method. Do stocktaking on}} \L{\LB{____\* cooler stocks and put in order if low on stock}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{public}_\K{void}_\V{performStocktaking}()}} \L{\LB{___\{}} \L{\LB{______\V{numberOfInventory}_\-=_\V{numberOfCoolersUsed};}} \L{\LB{______\K{if}_(\V{numberOfInventory}_\<=_\V{reorderingLimit})}} \L{\LB{_________\V{putInOrder}_=_\K{true};}} \L{\LB{___\}}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method : showInternals}} \L{\LB{____\* Return type : void}} \L{\LB{____\* Arguments : CoolerComponent object that will be displayed}} \L{\LB{____\* Description : Display the makeup of a cooler object}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{public}_\K{void}_\V{showInternals}(\V{CoolerComponent}_\V{aCooler})}} \L{\LB{___\{}} \L{\LB{______\V{app}.\V{objectInfoPanel}.\V{classNameText}.\V{setText}(\V{aCooler}.\V{getClass}().\V{getName}());}} \L{\LB{______\V{app}.\V{objectInfoPanel}.\V{inheritedClassNameText}.\V{setText}(\V{aCooler}.\V{getClass}().\V{getSuperclass}().\V{getName}());}} \L{\LB{______\V{app}.\V{objectInfoPanel}.\V{setAttrArea}(\V{aCooler}.\V{getAttributes}());}} \L{\LB{______\V{app}.\V{objectInfoPanel}.\V{setMethArea}(\V{aCooler}.\V{getMethods}());}} \L{\LB{___\}}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method : getAttributes}} \L{\LB{____\* Return type : string containing all the attributes of object}} \L{\LB{____\* Arguments : none}} \L{\LB{____\* Description : Override CarManufacturingComponent method. Group all}} \L{\LB{____\* attributes in CoolerComponent object for displaying.}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{private}_\V{String}_\V{getAttributes}()}} \L{\LB{___\{}} \L{\LB{______\V{StringBuffer}_\V{contained}_=_\K{new}_\V{StringBuffer}();}} \L{\LB{}} \L{\LB{______\V{contained}.\V{append}(\S{}\"int___numberOfCoolersUsed\2n\"\SE{});}} \L{\LB{}} \L{\LB{______\K{return}_\V{contained}.\V{toString}();}} \L{\LB{___\}}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method : getMethods}} \L{\LB{____\* Return type : string containing all methods to a CoolerComponent object}} \L{\LB{____\* Arguments : none}} \L{\LB{____\* Description : Override CarManufacturingComponent method. Group all methods}} \L{\LB{____\* of a CoolerComponent object for displaying}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{private}_\V{String}_\V{getMethods}()}} \L{\LB{___\{}} \L{\LB{______\V{StringBuffer}_\V{contained}_=_\K{new}_\V{StringBuffer}();}} \L{\LB{}} \L{\LB{______\V{contained}.\V{append}(\S{}\"Public\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"___Instance_methods\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"______CoolerComponent(CarSim_app)\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"______boolean_beginCoolerAssembling()\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"______void_showInternals(CoolerComponent_aCooler)\2n\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"___Overridden_methods\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"______void_performStocktaking()\2n\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"Private\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"___Overridden_methods\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"______String_getAttributes()\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"______String_getMethods()\2n\2n\"\SE{});}} \L{\LB{}} \L{\LB{______\K{return}_\V{contained}.\V{toString}();}} \L{\LB{___\}}} \L{\LB{\}}} \L{\LB{\C{}\1\* ========== CoolerComponent.class ends ========== \*\1\CE{}}} \L{\LB{}} \L{\LB{\C{}\1\* ========== LightsComponent.class begins ================================}} \L{\LB{_\*}} \L{\LB{_\* Class : LightsComponent}} \L{\LB{_\* Inherits from : AssemblyLineComponent}} \L{\LB{_\* Description : A makeup class for user interaction.}} \L{\LB{_\* Written by : Vi Huynh}} \L{\LB{_\* Creation date : 15 December 1996}} \L{\LB{_\* Last modified : 17 December 1996}} \L{\LB{_\*}} \L{\LB{_\* ======================================================================== \*\1\CE{}}} \L{\LB{\K{class}_\V{LightsComponent}_\K{extends}_\V{AssemblyLineComponent}}} \L{\LB{\{}} \L{\LB{___\K{int}_\V{numberOfLightsUsed};}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method :}} \L{\LB{____\* Return type :}} \L{\LB{____\* Arguments :}} \L{\LB{____\* Description :}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{public}_\V{LightsComponent}(\V{CarSim}_\V{app})}} \L{\LB{___\{}} \L{\LB{______\C{}\1\1_ initialise variables}} \CE{}\L{\LB{______\K{this}.\V{app}_=_\V{app};}} \L{\LB{______\V{numberOfWorkers}_=_4;}} \L{\LB{______\V{numberOfInventory}_=_40;}} \L{\LB{______\V{numberOfLightsUsed}_=_0;}} \L{\LB{______\V{putInOrder}_=_\K{false};}} \L{\LB{______\V{reorderingLimit}_=_10;}} \L{\LB{}} \L{\LB{______\C{}\1\1_ object size}} \CE{}\L{\LB{______\V{topLeftX}_=_101;}} \L{\LB{______\V{topLeftY}_=_399;}} \L{\LB{______\V{bottomRightX}_=_151;}} \L{\LB{______\V{bottomRightY}_=_433;}} \L{\LB{___\}}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method : beginLightsAssembling}} \L{\LB{____\* Return type : boolean - indicate the completion of lights assembling}} \L{\LB{____\* Arguments : none}} \L{\LB{____\* Description : Makeup method that will show the assembling of lights to}} \L{\LB{____\* car on assembly line}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{public}_\K{boolean}_\V{beginLightsAssembling}()}} \L{\LB{___\{}} \L{\LB{______\K{if}_(\V{putInOrder})}} \L{\LB{______\{}} \L{\LB{_________\K{int}_\V{newInventory}_=_30;______________\C{}\1\1_ arbitrarily enhanced inventory}} \CE{}\L{\LB{_________\V{numberOfInventory}_+=_\V{newInventory};__\C{}\1\1_ level}} \CE{}\L{\LB{_________\V{putInOrder}_=_\K{false};}} \L{\LB{______\}}} \L{\LB{______\K{if}_(\V{assembleFrontLights}())}} \L{\LB{______\{}} \L{\LB{_________\V{assembleRearLights}();}} \L{\LB{______\}}} \L{\LB{______\V{performStocktaking}();}} \L{\LB{______\K{return}_\K{true};}} \L{\LB{___\}}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method : assembleFrontLights}} \L{\LB{____\* Return type : boolean - indicate the completion of front lights assembling}} \L{\LB{____\* Arguments : none}} \L{\LB{____\* Description : Makeup method that show the assembling of front lights}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{private}_\K{boolean}_\V{assembleFrontLights}()}} \L{\LB{___\{}} \L{\LB{______\V{numberOfLightsUsed}_+=_4;}} \L{\LB{______\K{return}_\K{true};}} \L{\LB{___\}}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method : assembleRearLights}} \L{\LB{____\* Return type : boolean - indicate the completion of rear light assembling}} \L{\LB{____\* Arguments : none}} \L{\LB{____\* Description : Makeup method that show the assembling of rear lights}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{private}_\K{boolean}_\V{assembleRearLights}()}} \L{\LB{___\{}} \L{\LB{______\V{numberOfLightsUsed}_+=_4;}} \L{\LB{______\K{return}_\K{true};}} \L{\LB{___\}}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method : performStocktaking}} \L{\LB{____\* Return type : void}} \L{\LB{____\* Arguments : none}} \L{\LB{____\* Description : Override AssemblyLineComponent method. Check stock levels}} \L{\LB{____\* in lights and place new order if low}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{public}_\K{void}_\V{performStocktaking}()}} \L{\LB{___\{}} \L{\LB{______\V{numberOfInventory}_\-=_\V{numberOfLightsUsed};}} \L{\LB{______\K{if}_(\V{numberOfInventory}_\<=_\V{reorderingLimit})}} \L{\LB{______\{}} \L{\LB{_________\V{putInOrder}_=_\K{true};}} \L{\LB{______\}}} \L{\LB{___\}}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method : showInternals}} \L{\LB{____\* Return type : void}} \L{\LB{____\* Arguments : LightsComponent object to be dispalyed}} \L{\LB{____\* Description : Show the makeup of a LightsComponent object}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{public}_\K{void}_\V{showInternals}(\V{LightsComponent}_\V{aLights})}} \L{\LB{___\{}} \L{\LB{______\V{app}.\V{objectInfoPanel}.\V{classNameText}.\V{setText}(\V{aLights}.\V{getClass}().\V{getName}());}} \L{\LB{______\V{app}.\V{objectInfoPanel}.\V{inheritedClassNameText}.\V{setText}(\V{aLights}.\V{getClass}().\V{getSuperclass}().\V{getName}());}} \L{\LB{______\V{app}.\V{objectInfoPanel}.\V{setAttrArea}(\V{aLights}.\V{getAttributes}());}} \L{\LB{______\V{app}.\V{objectInfoPanel}.\V{setMethArea}(\V{aLights}.\V{getMethods}());}} \L{\LB{___\}}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method : getAttributes}} \L{\LB{____\* Return type : stirng containing all attributes in LightsComponent object}} \L{\LB{____\* Arguments : none}} \L{\LB{____\* Description : Override CarManufacturingComponent method. Group all attributes}} \L{\LB{____\* in LightsComponent object for displaying}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{private}_\V{String}_\V{getAttributes}()}} \L{\LB{___\{}} \L{\LB{______\V{StringBuffer}_\V{contained}_=_\K{new}_\V{StringBuffer}();}} \L{\LB{}} \L{\LB{______\V{contained}.\V{append}(\S{}\"int___numberOfLightsUsed\2n\"\SE{});}} \L{\LB{}} \L{\LB{______\K{return}_\V{contained}.\V{toString}();}} \L{\LB{___\}}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method : getMethods}} \L{\LB{____\* Return type : string containing all methods to a LightsComponent object}} \L{\LB{____\* Arguments : none}} \L{\LB{____\* Description : Override CarManufacturingComponent method. Group all methods}} \L{\LB{____\* a LightsComponent object for displaying}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{private}_\V{String}_\V{getMethods}()}} \L{\LB{___\{}} \L{\LB{______\V{StringBuffer}_\V{contained}_=_\K{new}_\V{StringBuffer}();}} \L{\LB{}} \L{\LB{______\V{contained}.\V{append}(\S{}\"Public\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"___Instance_methods\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"______LightsComponent(CarSim_app)\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"______boolean_beginLightsAssembling()\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"______void_showInternals(LightsComponent_aLights)\2n\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"___Overridden_methods\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"______void_performStocktaking()\2n\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"Private\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"___Instance_methods\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"______boolean_assembleFrontLights()\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"______boolean_assembleRearLights()\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"___Overridden_methods\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"______String_getAttributes()\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"______String_getMethods()\2n\2n\"\SE{});}} \L{\LB{}} \L{\LB{______\K{return}_\V{contained}.\V{toString}();}} \L{\LB{___\}}} \L{\LB{\}}} \L{\LB{\C{}\1\* ========== LightsComponent.class ends ========== \*\1\CE{}}} \L{\LB{}} \L{\LB{\C{}\1\* ========== FrontPanelComponent.class begins ============================}} \L{\LB{_\*}} \L{\LB{_\* Class : FrontPanelComponent}} \L{\LB{_\* Inherits from : AssemblyLineComponent}} \L{\LB{_\* Description : A makeup class for user interaction.}} \L{\LB{_\* Written by : Vi Huynh}} \L{\LB{_\* Creation date : 15 December 1996}} \L{\LB{_\* Last modified : 17 December 1996}} \L{\LB{_\*}} \L{\LB{_\* ======================================================================== \*\1\CE{}}} \L{\LB{\K{class}_\V{FrontPanelComponent}_\K{extends}_\V{AssemblyLineComponent}}} \L{\LB{\{}} \L{\LB{___\K{int}_\V{numberOfPanelsUsed};}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method : FrontPanelComponent}} \L{\LB{____\* Return type : none}} \L{\LB{____\* Arguments : a CarSim object that will be referenced in class}} \L{\LB{____\* Description : Constructor to FrontPanelComponent class}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{public}_\V{FrontPanelComponent}(\V{CarSim}_\V{app})}} \L{\LB{___\{}} \L{\LB{______\K{this}.\V{app}_=_\V{app};}} \L{\LB{______\V{numberOfWorkers}_=_2;}} \L{\LB{______\V{numberOfInventory}_=_5;}} \L{\LB{______\V{numberOfPanelsUsed}_=_0;}} \L{\LB{______\V{putInOrder}_=_\K{false};}} \L{\LB{______\V{reorderingLimit}_=_3;}} \L{\LB{}} \L{\LB{______\V{topLeftX}_=_317;}} \L{\LB{______\V{topLeftY}_=_222;}} \L{\LB{______\V{bottomRightX}_=_380;}} \L{\LB{______\V{bottomRightY}_=_256;}} \L{\LB{___\}}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method : beginFrontPanelAssembling}} \L{\LB{____\* Return type : boolean - indicate the completion of aseembling front}} \L{\LB{____\* panel to car}} \L{\LB{____\* Arguments : none}} \L{\LB{____\* Description : Makeup method that show the assembling of a front panel to}} \L{\LB{____\* car}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{public}_\K{boolean}_\V{beginFrontPanelAssembling}()}} \L{\LB{___\{}} \L{\LB{______\K{if}_(\V{putInOrder})}} \L{\LB{______\{}} \L{\LB{_________\K{int}_\V{newInventory}_=_5;______________\C{}\1\1_ arbitrarily enhanced inventory}} \CE{}\L{\LB{_________\V{numberOfInventory}_+=_\V{newInventory};__\C{}\1\1_ level}} \CE{}\L{\LB{_________\V{putInOrder}_=_\K{false};}} \L{\LB{______\}}} \L{\LB{______\V{app}.\V{getAppletContext}().\V{showStatus}(\S{}\"Fitting_FRONT_PANEL_to_the_front_of_the_car.\,.\,.\"\SE{});}} \L{\LB{______\V{numberOfPanelsUsed}_+=_1;}} \L{\LB{______\V{performStocktaking}();}} \L{\LB{______\K{return}_\K{true};}} \L{\LB{___\}}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method : performStocktaking}} \L{\LB{____\* Return type : void}} \L{\LB{____\* Arguments : none}} \L{\LB{____\* Description : Override AssemblyLineComponent method. Check level of}} \L{\LB{____\* stock in front panels and place new order if low.}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{public}_\K{void}_\V{performStocktaking}()}} \L{\LB{___\{}} \L{\LB{______\V{numberOfInventory}_\-=_\V{numberOfPanelsUsed};}} \L{\LB{______\K{if}_(\V{numberOfInventory}_\<=_\V{reorderingLimit})}} \L{\LB{_________\V{putInOrder}_=_\K{true};}} \L{\LB{___\}}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method : showInternals}} \L{\LB{____\* Return type : void}} \L{\LB{____\* Arguments : FrontPanelComponent object to be displayed}} \L{\LB{____\* Description : show the makeup of FrontPanelComponent object}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{public}_\K{void}_\V{showInternals}(\V{FrontPanelComponent}_\V{aFrontPanel})}} \L{\LB{___\{}} \L{\LB{______\V{app}.\V{objectInfoPanel}.\V{classNameText}.\V{setText}(\V{aFrontPanel}.\V{getClass}().\V{getName}());}} \L{\LB{______\V{app}.\V{objectInfoPanel}.\V{inheritedClassNameText}.\V{setText}(\V{aFrontPanel}.\V{getClass}().\V{getSuperclass}().\V{getName}());}} \L{\LB{______\V{app}.\V{objectInfoPanel}.\V{setAttrArea}(\V{aFrontPanel}.\V{getAttributes}());}} \L{\LB{______\V{app}.\V{objectInfoPanel}.\V{setMethArea}(\V{aFrontPanel}.\V{getMethods}());}} \L{\LB{___\}}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method : getAttributes}} \L{\LB{____\* Return type : string containging all attributes in a FrontPanelComponent}} \L{\LB{____\* object}} \L{\LB{____\* Arguments : none}} \L{\LB{____\* Description : Override CarManufacturingComponent method. Group all attributes}} \L{\LB{____\* in FrontPanelComponent object for displaying}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{private}_\V{String}_\V{getAttributes}()}} \L{\LB{___\{}} \L{\LB{______\V{StringBuffer}_\V{contained}_=_\K{new}_\V{StringBuffer}();}} \L{\LB{}} \L{\LB{______\V{contained}.\V{append}(\S{}\"int___numberOfPanelsUsed\2n\"\SE{});}} \L{\LB{}} \L{\LB{______\K{return}_\V{contained}.\V{toString}();}} \L{\LB{___\}}} \L{\LB{}} \L{\LB{___\C{}\1\*}} \L{\LB{____\* Method : getMethods}} \L{\LB{____\* Return type : string containing all methods to FrontPanelComponent}} \L{\LB{____\* object}} \L{\LB{____\* Arguments : none}} \L{\LB{____\* Description : Override CarManufacturingComponent method. Group all methods}} \L{\LB{____\* in FrontPanelComponent object for displaying.}} \L{\LB{____\*\1\CE{}}} \L{\LB{___\K{private}_\V{String}_\V{getMethods}()}} \L{\LB{___\{}} \L{\LB{______\V{StringBuffer}_\V{contained}_=_\K{new}_\V{StringBuffer}();}} \L{\LB{}} \L{\LB{______\V{contained}.\V{append}(\S{}\"Public\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"___Instance_methods\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"______FrontPanelComponent(CarSim_app)\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"______boolean_beginFrontPanelAssembling()\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"______void_showInternals(FrontPanelComponent_aFrontPanel)\2n\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"___Overridden_methods\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"______void_performStocktaking()\2n\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"Private\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"___Overridden_methods\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"______String_getAttributes()\2n\"\SE{});}} \L{\LB{______\V{contained}.\V{append}(\S{}\"______String_getMethods()\2n\2n\"\SE{});}} \L{\LB{}} \L{\LB{______\K{return}_\V{contained}.\V{toString}();}} \L{\LB{___\}}} \L{\LB{\}}} \L{\LB{\C{}\1\* ========== FrontPanelComponent.class ends ========== \*\1\CE{}}} \end{lgrind}