Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

public class Parcel { private double weight; / / The parcels weight in kilos private int width; / / the parcel's width in cms private

public class Parcel
{
private double weight; //The parcels weight in kilos
private int width; // the parcel's width in cms
private int length; //the parcel's length in cms
private int height; //The parcel's height in cms
/** the maximum permissible length of the parcel in cms */
public static final int LENGTH_LIMIT =120;
/** the maximum permissible size of the parcel in cms */
public static final int SIZE_LIMIT =245;
/** the maximum permissible size of the parcel in kilos */
public static final int WEIGHT_LIMIT =5;
/**
* @return the weight
*/
public double getWeight()
{
return weight;
}
///**
//* Equals method for this object.
//* @return true if objects compared are same class or subclass and
//* have the same address and dateSent
//*/
// public boolean equals(Object o)
//{
// if(o != null && o instanceof Parcel)
//{
// Parcel p =(Parcel) o;
// return getAddress().equals(p.getAddress()) && getDateSent().equals(p.getDateSent());
//}
// return false;
//}
///**
//*
//* @return a string representation of the parcel
//*/
// public String toString()
//{
// String returnString = "A parcel for "+ getAddress()+"
Weight "+ weight +
//"Kg, Width "+ width +"cms, Height "+ height +"cms, Length "+ length +"cms.";
// return returnString;
//}
}
In this part you will complete the class Parcel, which already has the following private fields:
weight, of type double, the weight of the parcel in kilos,
width, of type int, which holds the width of the parcel in cms,
length, of type int, which holds the length of the parcel in cms,
height, of type int, which holds the height of the parcel in cms.
In addition, there are three public integer class constants:
LENGTH_LIMIT, the maximum length of a parcel that can be carried,
SIZE_LIMIT, the maximum size (derived from a formula supplied by the courier company),
WEIGHT_LIMIT, the maximum weight in kilos.
The class has a getter method for weight as well as equals and toString methods, which are initially commented out.
i.Alter the header of Parcel so it inherits from Freight and add a public constructor to the class Parcel with the signature:
Parcel(String, double, int, int, int)
The constructors first parameter is used to set the address, and the other four parameters to set the values of the four instance fields of Parcel in the order described above.
The field dateSent should be set to an empty string.
Uncomment the provided methods equals and toString.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning Microsoft SQL Server 2012 Programming

Authors: Paul Atkinson, Robert Vieira

1st Edition

1118102282, 9781118102282

More Books

Students also viewed these Databases questions

Question

4. How would you deal with the store manager?

Answered: 1 week ago