Giter Club home page Giter Club logo

hw_week2_day2_interfaces's Introduction

HW_Week2_Day2_Interfaces

The Home Work has to be delievered before 9AM: ⚠️

Note: You must save all your solution as solution.kt to be submitted before 9AM. ⚠️

Instructions 📋

Write an interface named 'IVehicle' with following features:

Interfce properties:

  • type: string value

Interfce functions:

  • isMoving()

Write a class named 'Vehicle' which implements from IVehicle interface with following features:

Properties:

  • startEngine: boolean value for the engine state
  • speed: int value for the speed of the vehicle
  • gear: int value for the gear number of the vehicle

class functions:

  • isMoving(): Check if speed more than zero then reterns true otherwise false.
  • speedUp(): Increments speed value.
  • changeGear(int): Changes gear's numbers.
  • applyBrakes(): Sets the speed to zero.
  • setType(String): Sets the type of the vehicle.
  • printStates(): Print the state of the vehicle either is moving or not.

Write a subclass named 'SportCar' which inherents from Vehicle class with following features:

Class functions:

  • changeGear(int): Checks the engine if it started it will change the gear number to a number between 1 and 5 otherwise sets to zero.
  • speedUp(): Increments speed value by 20.

Write a subclass named 'Truck' which inherents from Vehicle class with following features:

Class functions:

  • changeGear(int): Checks the engine if it started it will change the gear number to a number between 1 and 10 otherwise sets to zero.
  • speedUp(): Increments speed value by 5.

Output:

SportCar present state : (Moving)
speed: 80 gear: 5
Truck present state : (Moving)
speed: 40 gear: 2
Truck present state : (Stopped)
speed: 0 gear: 0

hw_week2_day2_interfaces's People

Contributors

aalherz avatar sampaddock avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.