
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Question
![The following class represents a 3d shape using an array of 3dPoints. It is intended
to be immutable. Assume the 3dPoint class is immutable.
Some of these functions, by their nature, make the class mutable and should be
removed completely to make it immutable.
Some others might make the class mutable, but it is possible to make them safe by
implementing them carefully.
Others are mostly safe in an immutable class.
Determine which functions should be removed, which must be carefully
implemented, and which are safe.
public class 3dShape{
private 3dPoint points;
public 3dShape(3dPoint [] points);
// Sets the point array member to the given point array
public void setPoints (3dPoint[] points);
// Returns the point aray member
public 3dPoint[] getPoints();
// Returns the volume of the shape represented by the point
public double getVolume();
// Stretches the shape by the percent specified in each direction
public void stretch(double x, double y, double z);
}
The function setPoints needs to be carefully implemented to make the class
immutable.
The function getPoints does not need special attention to make the class immutable.
The function getVolume needs to be carefully implemented to make the class
immutable.
The function stretch needs to be removed to make the class immutable.](https://content.bartleby.com/qna-images/question/bc064630-90b9-4865-ab90-047d3f200edb/68f38c5f-d583-41de-8cec-9e9b521a8160/efpy6_thumbnail.jpeg)
Transcribed Image Text:The following class represents a 3d shape using an array of 3dPoints. It is intended
to be immutable. Assume the 3dPoint class is immutable.
Some of these functions, by their nature, make the class mutable and should be
removed completely to make it immutable.
Some others might make the class mutable, but it is possible to make them safe by
implementing them carefully.
Others are mostly safe in an immutable class.
Determine which functions should be removed, which must be carefully
implemented, and which are safe.
public class 3dShape{
private 3dPoint points;
public 3dShape(3dPoint [] points);
// Sets the point array member to the given point array
public void setPoints (3dPoint[] points);
// Returns the point aray member
public 3dPoint[] getPoints();
// Returns the volume of the shape represented by the point
public double getVolume();
// Stretches the shape by the percent specified in each direction
public void stretch(double x, double y, double z);
}
The function setPoints needs to be carefully implemented to make the class
immutable.
The function getPoints does not need special attention to make the class immutable.
The function getVolume needs to be carefully implemented to make the class
immutable.
The function stretch needs to be removed to make the class immutable.

Transcribed Image Text:(Edgar)
Select the functions from the following list that could belong to an ADT. Remember
that not all ADTs are immutable. (Hint: ask yourself if these methods belong in an
idealistic ADT, i.e. one truly meeting the ADT design rule.)
Account ADT
// Accepts an int and sets the account's opening year to that
setYear(int year)
Bag ADT
// Sets the max capacity of the bag to the given integer
setMaxCapacity (int capacity)
Queue ADT
// Sets the queues internal ArrayList to the given ArrayList
setContents(ArrayList contents)
Queue ADT
// remove the least recently added item
dequeue() throws ArrayOutOfBounds Exception
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 2 steps

Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Is there a different way of doing this problem? Question: Create a class AccessPoint with the following attributes: x - a double representing the x coordinate y - a double representing the y coordinate range - an integer representing the coverage radius status - On or Off Add constructors. The default constructor should create an access point object at position (0.0, 0.0), coverage radius 0, and Off. Add accessor and mutator functions: getX, getY, getRange, getStatus, setX, setY, setRange and setStatus. Also, add a set function that sets the location coordinates and the range. Add the following member functions: move and coverageArea. Add a function overlap that checks if two access points overlap their coverage and returns true if they overlap. Add a function signalStrength that returns the wireless signal strength as a percentage. The signal strength decreases as one moves away from the access point location. Test your class by writing a main function that creates five access…arrow_forwardI need help in improving my code. This is an elevator simulator that uses polymorphism and object-oriented programming to simulate the movement of elevators in a building with multiple types of passengers and elevators.The system has 8 elevators, each of which can be one of 4 types of elevators, with a certainpercentage of requests for each type. Similarly, each passenger can be one of 4 types, with adifferent percentage of requests for each type. The simulation should have 4 types of Passengers: Standard: This is the most common type of passenger and has a request percentage of 70%. Standard passengers have no special requirements. VIP: This type of passenger has a request percentage of 10%. VIP passengers are given priority and are more likely to be picked up by express elevators. Freight: This type of passenger has a request percentage of 15%. Freight passengers have large items that need to be transported and are more likely to be picked up by freight elevators. Glass: This type…arrow_forwardComplete the Course class by implementing the courseSize() method, which returns the total number of students in the course. Given classes: Class LabProgram contains the main method for testing the program. Class Course represents a course, which contains an ArrayList of Student objects as a course roster. (Type your code in here.) Class Student represents a classroom student, which has three fields: first name, last name, and GPA. Ex. For the following students: Henry Bendel 3.6 Johnny Min 2.9 the output is: Course size: 2 public class LabProgram { public static void main (String [] args) { Course course = new Course(); // Example students for testing course.addStudent(new Student("Henry", "Bendel", 3.6)); course.addStudent(new Student("Johnny", "Min", 2.9)); System.out.println("Course size: " + course.courseSize()); } } public class Student { private String first; // first name private String last; // last name private…arrow_forward
- Lab 10 Using an interface to share methods It is often the case that two or more classes share a common set of methods. For programming purposes we might wish to treat the objects of those classes in a similar way by invoking some of their common routines.For example, the Dog and Cat classes listed below agree on the void method speak. Because Dog and Cat objects have the ability to “speak,” it is natural to think of putting both types of objects in an ArrayList and invoking speak on every object in the list. Is this possible? Certainly we could create an ArrayList of Dog that would hold all the Dog objects, but can we then add a Cat object to an ArrayList of Dog?Try running the main program below as it is written. Run it a second time after uncommenting the line that instantiates a Cat object and tries to add it to the ArrayList. import java.util.*;public class AnimalRunner{ public static void main(String[] args) { ArrayList<Dog> dogcatList = new ArrayList<Dog>();…arrow_forwardImplement a nested class composition relationship between any two class types from the following list: Advisor Вook Classroom Department Friend Grade School Student Teacher Tutor Write all necessary code for both classes to demonstrate a nested composition relationship including the following: a. one encapsulated data member for each class b. inline default constructor using constructor delegation for each class c. inline one-parameter constructor for each class d. inline accessors for all data members e. inline mutators for all data membersarrow_forwardHelp, I am making a elevator simulation using polymorphism. I am not sure to do now. Any help would be appreciated. My code is at the bottom, that's all I could think off. There are 4 types of passengers in the system:Standard: This is the most common type of passenger and has a request percentage of 70%. Standard passengers have no special requirements.VIP: This type of passenger has a request percentage of 10%. VIP passengers are given priority and are more likely to be picked up by express elevators.Freight: This type of passenger has a request percentage of 15%. Freight passengers have large items that need to be transported and are more likely to be picked up by freight elevators.Glass: This type of passenger has a request percentage of 5%. Glass passengers have fragile items that need to be transported and are more likely to be picked up by glass elevators. public abstract class Passenger { public static int passangerCounter = 0; private String passengerID; protected…arrow_forward
- All vehicles used for transportation in the U.S. must have identification, which varies according to the type of vehicle. For example, all automobiles have a unique Vehicle Identification Number (VIN) assigned by the manufacturer, plus a license plate number assigend by the state in which the auto is registerd. Your task is to modify the Auto class below to override the equals method of the Vehicle class to test that the VIN and license plate number are identical.arrow_forwardAdhere to the following additional requirements: Each of the 6 classes will have exactly 2 constructors. Every class will have a getSpecies() function. We won't be declaring objects of type "Creature" or "Demon", but you should include getSpecies() functions for them anyway, and they should return "Creature" and "Demon", respectively. Make getSpecies() a public member instead of private. Each of the 5 derived classes will have exactly 4 member functions (including constructors) and no data members The Creature class will have 8 member functions (including 2 constructors, 2 accessors, and 2 mutators) and 2 data members. Do not use the "protected" keyword. Many computer programmers consider it to be poor practice because only the base class itself should have uncontrolled access to that data. The derived classes can access the data members through accessors and mutators. In the non-default constructors for the sub-classes, you will need to use initializer lists. The Creature class's…arrow_forwardWrite a class that tests and demonstrates that your Candidate and Electionclasses implement the specification given above. Note that this does not need to be a Junit test class.Your test class must illustrate all of the features that you have implemented. This will best be done by having at least one separate test method for each feature. For instance:• A method that creates a Candidate object and prints out the result of calling each of its accessor (get) methods; • A method that adds a vote to an existing Candidate object.• A method that creates an Election object, creates a few Candidateobjects and adds them to it, and then calls the printAll method;• A method that finds a matching Candidate;• A method that does not find a matching Candidate;• etc.Note that the list above is not a complete list of the test class’s methods and you will need to define more than those for this part. It will be worth writing this test class alongside writing the other classes. For instance, develop the…arrow_forward
- Hi, I am making a elevator simulation and I need help in making the passenger classes using polymorphism. Any help is appreciated. There are 4 types of passengers in the system:Standard: This is the most common type of passenger and has a request percentage of 70%. Standard passengers have no special requirements.VIP: This type of passenger has a request percentage of 10%. VIP passengers are given priority and are more likely to be picked up by express elevators.Freight: This type of passenger has a request percentage of 15%. Freight passengers have large items that need to be transported and are more likely to be picked up by freight elevators.Glass: This type of passenger has a request percentage of 5%. Glass passengers have fragile items that need to be transported and are more likely to be picked up by glass elevators. This is what I have so far // Passenger abstract classpublic abstract class Passenger { protected String type; protected int requestPercentage; public…arrow_forwardThe total cost of a group of items at a grocery store is based on the sum of the individual product prices and the tax (which is 5.75%). Products that are considered “necessities” are not taxed, whereas products that are considered “luxuries” are. The Product class is abstract, and it has a method called getTotalPrice. Your task is to create two subclasses of Product: NecessaryProduct and LuxuryProduct and implement the getTotalPrice method in each of these classes appropriately. Then modify the driver program to instantiate four products (two necessary and two luxury) and store them in the product array, print out each item in the array, and display the total cost of the items. You should not make any changes at all to Product.java, and you should only add to ShoppingTripStartingCode.java. Do not change any code that is already present Example(Cheese and bread are necessities and soda and candy are luxuries)Cheese…arrow_forwardThis is for pygame Ball Class: The Ball class inherits from Drawable and it will draw a circle at its current location. You must implement at the very least the required methods of the base class (draw and get_rect), as well as a constructor. You may need to implement other methods as part of the public interface. This is the Drawable Classarrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education

Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON

Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education