The Main class, ITrip interface, and SimpleTrip class have been provided for you. The remaining classes you will have to complete on your own. The Builder is responsible for building your trip by creating several ComplexTrip and SimpleTrip objects and connecting them. Your trip should start at Home and then visit North Adams and Pittsfield. While in North Adams you will visit MASSMoCA, with a stop at the Lewitt Exhibit and the Cafe, and then you will check out MCLA. While in Pittsfield you will visit the Science Museum and then catch a Baseball Game. When your program is working correctly, your program should produce the following output: Visiting Home Visiting North Adams Visiting MASSMoCA Visiting Lewitt Exhibit Visiting Cafe Visiting MCLA Visiting Pittsfield Visiting Science Museum Visiting Baseball Game
The Main class, ITrip interface, and SimpleTrip class have been provided for you. The remaining classes you will have to complete on your own. The Builder is responsible for building your trip by creating several ComplexTrip and SimpleTrip objects and connecting them.
Your trip should start at Home and then visit North Adams and Pittsfield. While in North Adams you will visit MASSMoCA, with a stop at the Lewitt Exhibit and the Cafe, and then you will check out MCLA. While in Pittsfield you will visit the Science Museum and then catch a Baseball Game.
When your
Visiting Home Visiting North Adams Visiting MASSMoCA Visiting Lewitt Exhibit Visiting Cafe Visiting MCLA Visiting Pittsfield Visiting Science Museum Visiting Baseball Game
import java.util.*;
import java.io.*;
public class Main
{
public static void main (String[] args) throws Exception
{
ITrip e = (Builder.getInstance()).createTrip();
e.travel();
}
}
public interface ITrip
{
public void travel();
}
public class SimpleTrip implements ITrip
{
private String m_location;
public SimpleTrip(String location)
{
m_location = location;
}
@Override
public void travel()
{
System.out.printf("Visiting %s%n", m_location);
}
}
public class Builder {
public ITrip createTrip() {
ComplexTrip t1 = new ComplexTrip("Home");
ComplexTrip t2 = new ComplexTrip("North Adams");
ComplexTrip t3 = new ComplexTrip("Pittsfield");
t1.add(t2).add(t3);
ComplexTrip t4 = new ComplexTrip("MassMoCA");
ComplexTrip t5 = new ComplexTrip("MCLA");
t2.add(t4).add(t5);
ITrip t6 = new ComplexTrip("Science Museum");
ITrip t7 = new ComplexTrip("Baseball Game");
t3.add(t6).add(t7);
ITrip t8 = new ComplexTrip("Lewitt Exhibit");
ITrip t9 = new ComplexTrip("Cafe");
t4.add(t8).add(t9);
return null;
}
public static ITrip getInstance() {
// TODO Auto-generated method stub
return null;
}
import java.util.ArrayList;
import java.util.List;
public class ComplexTrip {
private List<ITrip> m_trips;
public ComplexTrip(String location) {
}
public void travel() {
super.travel();
for(ITrip t: m_trips) {
t.travel();
}
}
public ComplexTrip add(ITrip trip) {
return (null);
}
}
![*SimpleTrip.java - Notepad
File Edit Format View Help
Ln 31, Col 1
100%
Unix (LF)
UTF-8
constructs trips
uses
<<interface>>
<<singleton>>
ITrip
Builder
Main
public void travel0
public ITrip createTrip0
SimpleTrip
private String m_location
public SimpleTrip(String location)
public void travel)
ComplexTrip
1.n
private List<ITrip> m_trips;
public ComplexTrip(String location)
public void travel0
public ComplexTrip add(ITrip trip)
The Main class, ITrip interface, and SimpleTrip class have been provided for you. The remaining classes you will have to complete on
your own. The Builder is responsible for building your trip by creating several ComplexTrip and SimpleTrip objects and connecting
them.
Your trip should start at Home and then visit North Adams and Pittsfield. While in North Adams you will visit MASSMOCA, with a stop at the
Lewitt Exhibit and the Cafe, and then you will check out MCLA. While in Pittsfield you will visit the Science Museum and then catch a
Baseball Game.
The following object diagram shows the objects (as well as the classes they belong to) that your Builder will have to create to build this
wonderful trip:
va - Notepad
Format View Help
11:26 AM
O Type here to search
a
51°F
4/23/2022
11](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F5b9fc713-35a7-4152-955e-ea0356866640%2F3c242dea-3478-4cc2-b90e-ae756d3c3dd3%2F5ksxd4t_processed.png&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 2 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Concepts of Database Management](https://www.bartleby.com/isbn_cover_images/9781337093422/9781337093422_smallCoverImage.gif)
![Prelude to Programming](https://www.bartleby.com/isbn_cover_images/9780133750423/9780133750423_smallCoverImage.jpg)
![Sc Business Data Communications and Networking, T…](https://www.bartleby.com/isbn_cover_images/9781119368830/9781119368830_smallCoverImage.gif)