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

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

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

 

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
Transcribed Image Text:*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
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY