task is to create jl unit testing ----CruiseShip.java----- package ShipDemo; /**
ID: 658600 • Letter: T
Question
task is to create jl unit testing
----CruiseShip.java-----
package ShipDemo;
/**
The CruiseShip class stores data about
a ship that is a cruise ship for the
Ship, CruiseShip, and CargoShip Classes
programming challenge.
*/
public class CruiseShip extends Ship
{
private int passengers; // Maximum number of passengers
/**
Constructor
@param n The ship's name.
@param y The year the ship was build.
@param p The maximum number of passengers.
*/
CruiseShip(String n, String y, int p)
{
// Call the superclass constructor (Ship),
// passing the name and year as arguments.
super(n, y);
// Set passengers.
passengers = p;
}
/**
setPassengers method
@param p The maximum number of passengers.
*/
public void setPassengers(int p)
{
passengers = p;
}
/**
getPassengers method
@return The ship's maximum number of passengers.
*/
public int getPassengers()
{
return passengers;
}
/**
toString method
@return A string indicating the ship's name
and the maximum number of passengers.
*/
public String toString()
{
return "Name: " + getName() + " Maximum passengers: " +
passengers;
}
}
-------CargoShip.java--------
package ShipDemo;
/**
The CargoShip class stores data about
a ship that is a cargo ship for the
Ship, CruiseShip, and CargoShip Classes
programming challenge.
*/
public class CargoShip extends Ship
{
private int tonnage; // Cargo tonnage
/**
Constructor
@param n The ship's name.
@param y The year the ship was build.
@param t The cargo tonnage.
*/
CargoShip(String n, String y, int t)
{
// Call the superclass constructor (Ship),
// passing the name and year as arguments.
super(n, y);
// Set tonnage.
tonnage = t;
}
/**
setTonnage method
@param t The maximum cargo tonnage.
*/
public void setTonnage(int t)
{
tonnage = t;
}
/**
getTonnage method
@return The ship's cargo capacity in tons.
*/
public int getTonnage()
{
return tonnage;
}
/**
toString method
@return A string indicating the ship's name
and the cargo capacity.
*/
public String toString()
{
return "Name: " + getName() + " Cargo capacity: " +
tonnage + " tons";
}
}
----------Ship.java-----------
package ShipDemo;
/**
The Ship class stores data about a ship for the
Ship, CruiseShip, and CargoShip Classes
programming challenge.
*/
public class Ship
{
private String name; // Ship name
private String yearBuilt; // Year it was built
/**
Constructor
@param n The ship's name.
@param y The year the ship was build.
*/
public Ship(String n, String y)
{
name = n;
yearBuilt = y;
}
/**
setName method
@param n The ship's name.
*/
public void setName(String n)
{
name = n;
}
/**
setYearBuilt method
@param y The year the ship was built.
*/
public void setYearBuilt(String y)
{
yearBuilt = y;
}
/**
getName method
@return The ship's name.
*/
public String getName()
{
return name;
}
/**
getYearBuilt method
@return The year the ship was built.
*/
public String getYearBuilt()
{
return yearBuilt;
}
/**
toString method
@return A string indicating the ship's name
and the year it was built.
*/
public String toString()
{
return "Name: " + name + " Year built: " +
yearBuilt;
}
}
--------------ShipDemo.java------------------
package ShipDemo;
/**
This program demonstrates a solution to the
Ship, CruiseShip, and CargoShip Classes
programming challenge.
*/
public class ShipDemo
{
public static void main(String[] args)
{
// Constant for the number of ships.
final int NUM_SHIPS = 3;
// Create an array of Ship references.
Ship[] ships = new Ship[NUM_SHIPS];
// Assign Ship objects to the array elements.
ships[0] = new Ship("Lolipop", "1960");
ships[1] = new CruiseShip("Disney Magic", "1998", 2400);
ships[2] = new CargoShip("Black Pearl", "1800", 50000);
// Call each object's toString method.
for (int index = 0; index < 3; index++)
{
System.out.println(ships[index]);
System.out.println("----------------------------");
}
}
}
Explanation / Answer
task is to create jl unit testing-
Julia language-
Julia is under rapid development and has an extensive test suite to verify functionality across multiple platforms. If
1-
julia> using Ship.Test
julia> @class 1 == 1
julia> @class 1 == 0
ERROR: class failed: 1 == 0
in error at error.jl:22
in default_handler at class.jl:20
in do_class at class.jl:40
julia> @class error(" when a superclass fails")
ERROR: class error(
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.