Ride.java This class represents any amusement park ride. Ride should never be instantiated. Instead, it should only serve as a superclass for more specific rides. Variables: For fields in Ride, use the most restrictive visibility modifier that allows the fields to be accessible from any subclass. String name This variable should be immutable after construction of an instance. double profits the total amount of money this ride has made, always initially 0 int lastInspection the number time ride has completed since the last inspection String[] passengers the names of passengers aboard this ride. Constructors: a) A constructor that takes in name, lastInspection, and passengers. passengers argument array must be deep copied to the corresponding instance field. should not simply copy the reference of the input array and assign it to the instance field. b) A constructor that takes in name, passengers, and sets lastInspection to 0.
Ride.java This class represents any amusement park ride. Ride should never be instantiated. Instead, it should only serve as a superclass for more specific rides. Variables: For fields in Ride, use the most restrictive visibility modifier that allows the fields to be accessible from any subclass. String name This variable should be immutable after construction of an instance. double profits the total amount of money this ride has made, always initially 0 int lastInspection the number time ride has completed since the last inspection String[] passengers the names of passengers aboard this ride. Constructors: a) A constructor that takes in name, lastInspection, and passengers. passengers argument array must be deep copied to the corresponding instance field. should not simply copy the reference of the input array and assign it to the instance field. b) A constructor that takes in name, passengers, and sets lastInspection to 0.
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
Given the following instructions and starter:
Would this be the right way to implement the variables and constructors?
I'm a bit confused on how to deep copy the passenger array.
![Ride.java
This class represents any amusement park ride. Ride should never be instantiated.
Instead, it should only serve as a superclass for more specific rides.
Variables:
For fields in Ride, use the most restrictive visibility modifier that allows the fields to be
accessible from any subclass.
String name
This variable should be immutable after construction of an instance.
double profits
the total amount of money this ride has made, always initially 0
int lastInspection
the number time ride has completed since the last inspection
String[] passengers
the names of passengers aboard this ride.
Constructors:
a) A constructor that takes in name, lastInspection, and passengers.
passengers argument array must be deep copied to the corresponding instance field.
should not simply copy the reference of the input array and assign it to the instance field.
b) A constructor that takes in name, passengers, and sets lastInspection to 0.](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F295c436f-1881-4143-81a2-89f6f40be87f%2F779ce80f-9296-414d-8f09-63479d25b96a%2Fiomzq2_processed.png&w=3840&q=75)
Transcribed Image Text:Ride.java
This class represents any amusement park ride. Ride should never be instantiated.
Instead, it should only serve as a superclass for more specific rides.
Variables:
For fields in Ride, use the most restrictive visibility modifier that allows the fields to be
accessible from any subclass.
String name
This variable should be immutable after construction of an instance.
double profits
the total amount of money this ride has made, always initially 0
int lastInspection
the number time ride has completed since the last inspection
String[] passengers
the names of passengers aboard this ride.
Constructors:
a) A constructor that takes in name, lastInspection, and passengers.
passengers argument array must be deep copied to the corresponding instance field.
should not simply copy the reference of the input array and assign it to the instance field.
b) A constructor that takes in name, passengers, and sets lastInspection to 0.
![public abstract class Ride {
private String name;
private double profits;
private int lastInspection;
private String[] passengers;
public Ride(String name, int lastInspection, String[] passengers) {
this.name = name;
this.profits = profits;
this.runsSinceInspection = runsSinceInspection;
}
this.passengers = new String[]passengers;
public Ride(String name, String[] passengers) {
this(name, 0, passengers);
}](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F295c436f-1881-4143-81a2-89f6f40be87f%2F779ce80f-9296-414d-8f09-63479d25b96a%2Fuu9hg7_processed.png&w=3840&q=75)
Transcribed Image Text:public abstract class Ride {
private String name;
private double profits;
private int lastInspection;
private String[] passengers;
public Ride(String name, int lastInspection, String[] passengers) {
this.name = name;
this.profits = profits;
this.runsSinceInspection = runsSinceInspection;
}
this.passengers = new String[]passengers;
public Ride(String name, String[] passengers) {
this(name, 0, passengers);
}
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 now
This is a popular solution!
Step by step
Solved in 4 steps with 3 images

Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question
Is there any other way to deep copy without having to create the helper method?
Solution
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.Recommended textbooks for you

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

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