Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

package edu.luc.etl.cs313.android.shapes.model; import java.util.List; /** * A shape visitor for calculating the bounding box, that is, the smallest * rectangle containing the shape. The resulting

image text in transcribed package edu.luc.etl.cs313.android.shapes.model; import java.util.List; /** * A shape visitor for calculating the bounding box, that is, the smallest * rectangle containing the shape. The resulting bounding box is returned as a * rectangle at a specific location. */ public class BoundingBox implements Visitor { // TODO entirely your job (except onCircle) @Override public Location onCircle(final Circle c) { final int radius = c.getRadius(); return new Location(-radius, -radius, new Rectangle(2 * radius, 2 * radius)); } @Override public Location onFill(final Fill f) { return f.getShape().accept(this); } @Override public Location onGroup(final Group g) { // Fill this method } @Override public Location onLocation(final Location l) { Location location = l.shape.accept(this); return new Location(l.x+location.x, l.y+location.y, location.shape); } @Override public Location onRectangle(final Rectangle r) { return new Location(0, 0, new Rectangle(r.getWidth(), r.getHeight())); } @Override public Location onStroke(final Stroke c) { return c.getShape().accept(this); } @Override public Location onOutline(final Outline o) { return o.getShape().accept(this); } @Override public Location onPolygon(final Polygon s) { // Fill this method } }
Fill on Polygon method

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Securing SQL Server Protecting Your Database From Attackers

Authors: Denny Cherry

2nd Edition

1597499471, 978-1597499477

More Books

Students also viewed these Databases questions