Question: write a parent class that describes a parcel (like a package, as shown below) and a child class that describes an overnight parcel . Use
write a parent class that describes a parcel (like a package, as shown below) and a child class that describes an overnight parcel. Use the provided Address class.
A parcel is described by:
- id (which might contain numbers and letters)
- weight (described as the number of pounds; a parcel could be less than 1 pound)
- destination address (uses the provided class)
An overnight parcel is described by id, weight, destination address and also:
- whether or not a signature is required upon delivery
public class Address {
private String name, street, city, state, zip;
public Address(String name, String street, String city, String state, String zip) {
this.name = name;
this.street = street;
this.city = city;
this.state = state;
this.zip = zip;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getStreet() {
return street;
}
public void setStreet(String street) {
this.street = street;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
public String getZip() {
return zip;
}
public void setZip(String zip) {
this.zip = zip;
}
@Override
public String toString() {
return name + " " + street + " " + city + ", " + state + " " + zip;
}
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
