Coder Social home page Coder Social logo

jcvivas / javaoophomework Goto Github PK

View Code? Open in Web Editor NEW

This project forked from rhalatiu/javaoophomework

0.0 0.0 0.0 140 KB

All Vehicles (e.g car, bike, horse, boat, plane) have the following behavior: they can be started, stopped and driven for a number of kms Implement a hierarchy of Car classes where: Car is a type of vehicle: properties of a car model which can not change: fuelTankSize, fuelType (PETROL, DIESEL, etc), gears (max 6), consumptionPer100Km (i.e

Java 100.00%

javaoophomework's Introduction

javaOOPHomework

All Vehicles (e.g car, bike, horse, boat, plane) have the following behavior:

they can be started, stopped and driven for a number of kms

Implement a hierarchy of Car classes where:

Car is a type of vehicle:

properties of a car model which can not change: fuelTankSize, fuelType (PETROL, DIESEL, etc), gears (max 6), consumptionPer100Km (i.e 4.7) properties that are configurable: availableFuel, tireSize(15, 17, etc) properties that are instance specific: chassisNumber Behavior:

a car can be driven for N kms in different gears; consumptionPer100Km is the consumption of the car in cruising mode (last gear). During a start() and a stop() the car keeps track of the how much it has consumed. On every start() the consumption stats are reset. API:

Car car = new Car(); // This should not compile.

Car car = new Dacia(27, "oiqe0934hkkadsn"); // This should not compile! If I want to create a Dacia car, I will need to create an instance of a Dacia model.

Car car = new Logan(27, "oiqe0934hkkadsn"); // Logan can extend from Dacia, while Dacia extends from Car

car.start();

car.shiftGear(1);

car.drive(0.01);// drives 0.01 KMs

car.shiftGear(2);

car.drive(0.02);

car.shiftGear(3);

car.drive(0.5);

car.shiftGear(4);

car.drive(0.5);

car.shiftGear(4);

car.drive(0.5);

car.shiftGear(5);

car.drive(10);

car.shiftGear(4);

car.drive(0.5);

car.shiftGear(3);

car.drive(0.1);

car.stop();

float availableFuel = car.getAvailableFuel();

float fuleConsumedPer100Km = car.getAverageFuelConsumption();

Vehicle vehicle = new VWGolf(30, "1987ddkshik289"); //available fuel and chassis number

vehicle.start();

vehicle.drive(1km);

vehicle.stop();

Car car = (Car) vehicle;

float availableFuel = car.getAvailableFuel();

float fuleConsumedPer100Km = car.getAverageFuelConsumption();

Task:

Implement the classes, abstract classes and interfaces according to the given information.

Create at least 2 car brands with 2 models for each (e.g Volkswagen: VWGolf, VWPassat; Mercedes: CKlasse, SKlasse).

Make sure each car has different consumption.

e.g

Some cars might have a 10% decrease every time they shift up.

Some cars might have an increase in consumption with larger tires.

javaoophomework's People

Contributors

rhalatiu 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.