CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2013

    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.
    The task:

    - 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)

  2. #2
    Join Date
    Jul 2005
    Currently in Mexico City

    Re: Help with java class, subclass

    Pretty enough to complete the task: http://lmgtfy.com/?q=java+interface+explained

    Recommended structure:
    - 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 02: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!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.