Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Complete clone (copy constructor portion), scale, and toString functions for Composite class. Note that I have provided you a clone function and a skeleton for

Complete clone (copy constructor portion), scale, and toString functions for Composite class. Note that I have provided you a clone function and a skeleton for a copy constructor. Complete the copy constructor. Note the hints in the toString function. In JAVA

import java.util.Scanner; public class Composite extends Polyhedron { /** * Collection of polyhedra of which * this composite polyhedron is composed */ private Polyhedron[] polyhedra; /** * Default Constructor */ Composite() { super("Composite"); polyhedra = null; } /** * Copy Constructor */ Composite(Composite src) { super("Composite"); } /** * Read all component polyhedra * * @pre polyhedra == null * && numPolyhedra == 0 */ public void read(Scanner scanner) { int numPolyhedra = scanner.nextInt(); polyhedra = new Polyhedron[numPolyhedra]; for (int i = 0; i < polyhedra.length; i++) { polyhedra[i] = Polyhedron.createAndRead(scanner); boundingBox.merge(polyhedra[i].getBoundingBox()); } } public Polyhedron clone() { return new Composite(this); } public void scale(double scalingFactor) { } /** * Scale all polyhedra */ public String toString() { StringBuilder bld = new StringBuilder(); bld.append(super.toString()); // Start your toString code here //end your toString code here return bld.toString(); } } 

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

Probabilistic Databases

Authors: Dan Suciu, Dan Olteanu, Christopher Re, Christoph Koch

1st Edition

3031007514, 978-3031007514

More Books

Students also viewed these Databases questions

Question

Q: Are training efforts appraised? How is this done?

Answered: 1 week ago