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:
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started