Hi I have written this code and I am having problems with the equals method and

Hi I have written this code and I am having problems with the equals method and hash method and some other problems when I run a check on the uni website. I just need you to run a check on the code against the requirements and make the necessary changes please.
These are the requirements:
Launch BlueJ, open the project TMA03_Q1 in the TMA03Download folder you unzipped earlier and then immediately save the project as TMA03_Q1_SolXX, in the TMA03Download folder, where XX represents your own initials.
The provided project contains the completed class ThemePark as well as the partially completed class Ride. You should make no changes to ThemePark.
In this part you will complete the class Ride which has been provided for you. Ride already has the following private fields as well as getter and setter methods for these and a toString method:
name, the name of the ride, which is a String.
carCapacity, of type int, which holds the capacity of a single car on the ride.
operational, of type boolean, which is true if the ride is running and otherwise false.
i.Add a public constructor to the class Ride with the modifier and header public Ride(String aName, int aCarCapacity)
The constructor uses its two parameters to set the values of the corresponding fields.
The field operational should be set to false.
(5 marks)
ii.Add an equals method to Ride that overrides the Object equals method and returns true if the ride name and car capacity of the argument are the same as this object’s and false otherwise. For the purpose of this method, objects of a subclass of Ride should not be considered equal.
(5 marks)
iii.Add a hashCode method to Ride that returns the sum of the ride name’s length and car capacity.
(5 marks)
b.In this part you will add a new class RollerCoaster which should extend Ride.
i.Begin by adding the new class called RollerCoaster as a subclass of Ride. Retain but edit the class comment to include your own name and the date and a description of the class RollerCoaster. Remove the sample field, constructor and method and add a private int field numberOfCars representing the number of cars the roller coaster ride has.
(5 marks)
ii.Write a public constructor for RollerCoaster with the signature RollerCoaster(String, int, int) to initialise the instance variables using its parameters. The third parameter will be used to set the number of cars the roller coaster has.
(5 marks)
iii.Write a public method getCapacity in RollerCoaster that returns the total capacity for the roller coaster, which is the ride carCapacity multiplied by the numberOfCars.
(5 marks)
iv.Write a toString method in RollerCoaster that overrides that in Ride and returns in addition to the superclass description of the ride the total capacity of the ride, in the following format:
has car capacity and is .
The total capacity of the ride is .
The total capacity needs to be replaced by the appropriate value for the current object.
Note that there is a newline character between the two sentences.
The first sentence should be provided by the Ride class toString method.
(5 marks)
v.Add an equals method to RollerCoaster which should override equals in Ride and return true if the ride name and capacity are the same. It should allow instances of subclasses to be considered equal.
(5 marks)
vi.Override the inherited hashCode method so that it returns a hash code using the Objects.hash method, to which you should pass the ride name and total capacity in that order.
(5 marks)
This is my code for (a):
import java.util.Objects;
/**
* Ride is a class that abstracts the common features
* of rides at a theme park. Rides have a single car that can
* take a certain number of people in them (their capacity).
*
* @author M250 Module Team
* @version v1
*/
public class Ride
{
private String name;
private int carCapacity;
private boolean operational;
public Ride(String name, int aCarCapacity)
{
this.name = name;
this.carCapacity = aCarCapacity;
this.operational = false;
}
/**
* Getter for the ride name.
* @return The name of the ride
*/
public String getName()
{
return name;
}
/**
* Setter for the ride name.
* @param the ride’s name
*/
public void setName(String aName)
{
name = aName;
}
/**
* Getter for the ride’s car capacity.
* @return The number of people a car can carry
*/
public int getCarCapacity()
{
return carCapacity;
}
/**
* Setter for the ride’s car capacity.
* @param aCapacity The capacity of a car on this ride
*/
public void setCarCapacity(int aCapacity)
{
carCapacity = aCapacity;
}
/**
* Getter for the operational status of the ride.
* @return the operational status of the ride
*/
public boolean isOperational()
{
return operational;
}
/**
* Setter for the operational status of this ride.
* @param rideState true if operational, otherwise false
*/
public void setOperational(boolean rideState)
{
operational = rideState;
}
/**
* Return a String representation of a Ride including
* its class name, allowing for extension by subclasses.
* @return the string representation of the ride
*/
@Override
public String toString()
{
String outputString = String.format(“%s %s has car capacity %d and”,
getClass().getSimpleName(), name, carCapacity);
if (operational) {
outputString += ” is running.”;
}
else {
outputString += ” is not running.”;
}
return outputString;
}
@Override
public boolean equals(Object obj)
{
if(this == obj)
return true;
if(!(obj instanceof Ride))
return false;
Ride ride = (Ride) obj;
return getCarCapacity() == ride.getCarCapacity() && Objects.equals(getName(), ride.getName());
}
@Override
public int hashCode()
{
return Objects.hash(getName().length()+getCarCapacity());
}
}
And this is my code for (b):
import java.util.Objects;
/**
* Write a description of class RollerCoaster here.
*
* @author (your name)
* @version (a version number or a date)
*/
class RollerCoaster extends Ride
{
// instance variables – replace the example below with your own
private int numberOfCars;
/**
* Constructor for objects of class RollerCoaster
*/
public RollerCoaster(String rollercoaster, int capacity, int numberofCars)
{
// initialise instance variables
super(rollercoaster, capacity);
this.numberOfCars = numberOfCars;
}
/**
* An example of a method – replace this comment with your own
*
* @param y a sample parameter for a method
* @return the sum of x and y
*/
public int getCapacity()
{
// put your code here
return getCarCapacity()*numberOfCars;
}
@Override
public String toString()
{
return super.toString() + “r” + “The total capacity of the ride is : ” + getCapacity();
}
@Override
public boolean equals(Object object)
{
RollerCoaster rollerCoaster = (RollerCoaster) object;
return super.equals(object) && numberOfCars == rollerCoaster.numberOfCars;
}
@Override
public int hashCode()
{
return Objects.hash(getName(), getCapacity());
}
}
I have attached pictures of the checks

Save your time - order a paper!

Get your paper written from scratch within the tight deadline. Our service is a reliable solution to all your troubles. Place an order on any task and we will take care of it. You won’t have to worry about the quality and deadlines

Order Paper Now