Git Product home page Git Product logo

jv-oop-advanced's Introduction

jv-oop-advanced

Solve the task using OOP principles

Task:

There are some figures of the following types: square, rectangle, right triangle, circle, isosceles trapezoid. You need to create corresponding classes for them(Square, Rectangle, RightTriangle, Circle, IsoscelesTrapezoid)

All figures have

  • state - all figures have color, but each figure type can also have one or several unique properties (radius for circle, firstLeg and secondLeg for right triangle, and so on).
  • behavior - we can obtain the area of any figure and are able to draw it. To 'draw' means to print out all information about a figure using System.out.println() (you shouldn't override the toString() method for this).

Think where you should declare these fields and methods: top-level class/interface / bottom-level classes.

In the main() method we need to create an array of figures (the size of the array can be 3 or 6, it doesn't matter). The first half of figures in this array should be generated with random parameters.

For this purpose create two more classes:

  • ColorSupplier with public String getRandomColor() method - for generating random color,
  • and FigureSupplier with the public Figure getRandomFigure() method - for generating figures with random properties.

The other half of the figures should have the same, default parameters.

For this purpose create a new method in the FigureSupplier class:

  • public Figure getDefaultFigure() - this method should always return a white circle with a radius of 10.

After generating the array, we need to display the entire list of objects that we have, for example:

 Figure: square, area: 25.0 sq. units, side: 5 units, color: blue
 Figure: triangle, area: 12.5 sq. units, firstLeg: 7 units, secondLeg: 5 units, color: yellow

jv-oop-advanced's People

Contributors

maliukdaria avatar sofasmile avatar boroda4436 avatar romandubovskyi avatar kseniiamakarova avatar resci avatar nacenik 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.