## CSE 131 Module 8: List Structures

### Bridges

• Like all extensions and bridges, you can turn this in as you demo module 8, OR you can demo it at an extension fest.
• This may be easier to undertake once you've seen module 10. Bridges are exercises that span multiple modules, so you may want to hold off on this until after module 10.
• If you want to start it earlier, ask questions about the superclasses, subclasses, and interfaces you find in this bridge.
• This bridge is typical of most software projects in the real world, in that you are given a mix of code that is already written with an assignment to write addiitonal code to achieve the desired functionality.

You are free to change any of the code you are given.

## Falling Arches

### Overview:

In the past labs, we have come to view recursion as a powerful paradigm for computation. Similarly, recursive data structures allow one to build large, interconnected using relatively little effort. In this bridge, you construct a model for simulating the shape of a catenary: the shape of our beloved St. Louis arch.

### Goals:

By the end of this lab, you should
• Gain more experiences with arrays and lists
• Gain more experience with iteration
• Gain an introduction to recursive data structures
• Understand how computation can help validate a model
• Understand the nature of simulation and approximation in computation science

### Before starting:

• Read over this entire document before you start.
• Make sure you understand the API you will be implementing.
• Ask questions if you are uncertain.

### Problem description:

Long before our city began its expansion into the NFL, the pioneers of our country expanded to the West, crossing the Mississippi and braving the perils of midwestern life. As a monument to their efforts, the City of St. Louis erected Eero Saarinen's famous Arch in 1965. Its grace, beauty, and elegance have inspired poets, musicians, and artists of the past five decades.

It's time that CSE131 had its turn.

A catenary is the shape made when you suspend a string by holding its ends, and let gravity pull on the string. If you look at a telephone wire strung between two poles, the shape you see is a catenary, though not one that would necessarily garner artistic praise.

It turns out that our Arch is also a catenary, but situated upside down.

How are we to simulate an catenary acting on a string? If we look really closely at the string, we see that it is composed of a series of mass points, with each adjacent pair of masses connected by a spring.

With gravity turned off, the picture is as shown in Figure 1(a).

 (a) (b) Gravity turned off After 100 iterations Figure 1. A sequence of masses connected by springs, at the beginning and end of the simulation.
Generally, the Javadoc is the best resource for understanding how the objects of this project's design relate to each other. Some notes follow but be sure to read the documentation carefully before you get started on writing code.
• Because there are different objects exerting forces, it is convenient to have an interface that provides a force. Take a look at the ForceProvider interface.
• The two objects implementing this interface are
• Gravity, which knows how much force to exert if it knows the mass upon which it is acting.
• SpringBetweenMasses, which knows how much force to exert if it knows its original (nominal) length and its current displacement.
• A SpringBetweenMasses is-a Spring that has-a two masses to which it is attached. One of those masses is viewed as fixed, and the other as movable, so that the force the SpringBetweenMasses exerts can be computed as acting in only one direction.
• A MassRect is-a Mass that can display itself as a rectangle.
• There are two extensions to Mass: FixedMass and MovableMass.
• A spring obeys Hook's Law.

After letting gravity have its way with the masses, and accounting for the springs between the masses, our picture as shown in Figure 1(b).