April 9th, 2013, 10:17 AM
Help with java class, subclass
I need help with my work. I'm no good at programming and we started learning java last week, yet we got a hard task to do and i have no idea how to do it. If you could help me with it I would be very grateful.
- implement a class 'motor' with fields 'currentSpeed', 'currentDirection', 'id' and methods 'turnLeft()', 'turnRight()'
- implement basic user interface for controlling the engine
- implement at least two subclasses for different/various electric motors (i.e. a stepperMotor, DCMotor, etc.)
- implement subclass-specific (hardware-dependant) methods
- implement output to see how it works
- implement input for choosing,initializing,operating the motors
Inputs (user can
- coosing a motor subclass
- initializing a motor
- determining state of a motor
- using the motor (left/right)
Outputs (we will see
- all public variables/fields that change value
- internal behaviour of hardware-dependant methods (i.e. logic value of the pins connected to motors)
April 17th, 2013, 02:53 PM
Re: Help with java class, subclass
Pretty enough to complete the task: http://lmgtfy.com/?q=java+interface+explained
- interface Engine (here go the methods declarations)
- class (can be abstract) Motor as Engine implementation (here go the motor methods implementation or their redeclaration)
- class Motor1 extending class Motor (here go the motor specific methods overrides)
- class Motor2 extending class Motor (here go the motor specific methods overrides)
- for test and runs you could use a separate class with the main function
Last edited by Xeel; April 17th, 2013 at 03:04 PM.
Wanna install linux on a vacuum cleaner. Could anyone tell me which distro sucks better?
I had a nightmare last night. I was dreaming that Iím 64-bit and my blanket is 32-bit and I couldnít cover myself with it, so Iíve spent the whole night freezing. And in the morning I find that my blanket just had fallen off the bed. =S (from: bash.org.ru)
//always looking for job opportunities in AU/NZ/US/CA/Europe :P
USE [code] TAGS! Read this FAQ if you are new here. If this post was helpful, please rate it!
Click Here to Expand Forum to Full Width
This is a CodeGuru survey question.