Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This file defines a Velociraptor object and should be a subclass of Dinosaur. The velociraptor runs a lot, which means they eat a greater amount

This file defines a Velociraptor object and should be a subclass of Dinosaur. The velociraptor runs a lot, which means they eat a greater amount of food compared to the regular dinosaur. Some velociraptors may belong to a pack in an enclosure or may hunt alone. Variables: In addition to the variables it inherits from its superclass, Velociraptor should also have the following variables: speed an int representing the speed of the velociraptor in miles per hour. An invalid value should be set to 30. The value is invalid if it is negative. pack a Pack object representing whether the dinosaur belongs to a pack or not. A dinosaur who is not part of a pack will have this variable set to null. Constructor(s): A constructor that takes in the name, height, width, weight, speed, and pack. A constructor that takes in the name and height and defaults the speed to 30, pack to null and all other variables to their default in Dinosaur. A copy constructor that deep copies all mutable instance variables of the old object to the new object. Methods: The following methods should be public. enclosureSize() o Returns a double representing the area of the enclosure where the dinosaur is located o If the dinosaur is not part of a pack, calculate the enclosure size by multiplying four times the width by the height. o If the dinosaur is part of a pack, calculate enclosure size by multiplying the size of the pack by the width by the height. o This method should override the enclosureSize() method from Dinosaur.java calculateFood() o Returns a double representing the amount of food, in pounds, needed to prepare for the dinosaurs meal o To calculate, multiply weight times the speed by the height. toString() o Returns the String representation of the object. o Should return a String in the following format:

requires a square foot enclosure and pounds of food. o If the dinosaur was part of a pack, return a string in the following format: is a family of dinosaurs of size ! requires a square foot enclosure and pounds of food. Getters and setters for each of the instance variables.

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

Step: 3

blur-text-image

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

Understanding Oracle APEX 5 Application Development

Authors: Edward Sciore

2nd Edition

1484209893, 9781484209899

More Books

Students also viewed these Databases questions

Question

(4) How much feedback am I giving them on their performance?

Answered: 1 week ago

Question

(2) How stretching are these goals?

Answered: 1 week ago