Book Image

Java 9 with JShell

By : Gaston C. Hillar
Book Image

Java 9 with JShell

By: Gaston C. Hillar

Overview of this book

The release of Java 9 has brought many subtle and not-so-subtle changes to the way in which Java programmers approach their code. The most important ones are definitely the availability of a REPL, known as JShell, which will make experiments and prototyping much more straightforward than the old IDE-based project-led approach. Another, more subtle change can be seen in the module system, which will lead to more modularized, maintainable code. The techniques to take full advantage of object-oriented code, functional programming and the new modularity features in Java 9 form the main subjects of this book. Each chapter will add to the full picture of Java 9 programming starting out with classes and instances and ending with generics and modularity in Java.
Table of Contents (23 chapters)
Java 9 with JShell
Credits
About the Author
Acknowledgement
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface
Index

Capturing real-world objects


We could easily recognize objects from Pitstop's artwork. We understood that each pattern is composed of many 2D geometric shapes and we recognized the different shapes that she used in all the examples we analyzed. Now, let's focus on one of the core requirements for the Web Service, which is calculating the required amounts of acrylic paint to produce the artwork. We must take into account the following data for each 2D shape included in the pattern in order to calculate the required materials and the amount of acrylic paint to produce each shape:

  • The line color

  • The perimeter

  • The fill color

  • The area

It is possible to use a specific color for the line that draws the borders of each shape, and therefore, we have to calculate the perimeter to use it as one of the values that will allow us to estimate the amount of acrylic paint that the user must buy to paint the border of each 2D shape. Then, we have to calculate the area to use it as one of the values that will...