Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!