Question: The code below is an implementation of the Builder Design Pattern to build Parcels for a specified weight. Draw the UML diagram of the classes

The code below is an implementation of the Builder Design Pattern to build Parcels for a specified weight. Draw the UML diagram of the classes and their interactions. Then write a class called ParcelTest which contains a main() method which demonstrates the correct use of the createParcel and Weight methods to create an instance of the Parcel class.

public class ParcelBuilder { public Double weight; public ParcelBuilder(){}; public ParcelBuilder Weight(Double weight){ this.weight= weight; return this; } public Parcel createParcel(){ return new Parcel(weight); } } public class Parcel { private Double weight; public Parcel(){}; public Parcel(Double weight){ this.weight = weight; }; public void Weight(Double weight){ this.weight = weight; } public String toString(){ return ("Parcel weight is " + weight); } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!