Sailing Ship Lab

After just over a year of zero c++ coding, I've come back to school and have been completely lost and my instructor gives us the first lab assuming we came fresh from the previous course, I am desperate for help.

Lab 1 - create a class than represents a sailing ship, for possible later use in a game or historical simulation.

Class name should be somthing like "sailb" (for sail boat)

The class should include the following data attributes:

string name // name of boat or ship (it is unlucky to sail on a ship with no name!)
double length // length in feet
double beam // width in feet (beam is the nautical term)
double displacement // on land we would call this weight. in pounds
double sail_area // in square feet
?? rig // this is the type of sails - square rig (like Columbus) or fore-and-aft (triangular - like a modern sailboat)
// you define how you want to store this - could be Boolean, integer code or string

You may add other attibutes if you need them. You want at least a default constructor, access and modify
functions for each data item. In addition, class should be able to calculate and report the following values,
calculated from the boat design.

- hull speed HS=1.34 * sqrt(length) : hull speed in knots (nautical miles / hour, 1 nautical mile = 1.1508 normal miles)

This is the maximum speed the ship can reach; at this speed the water resistance increases so much that sails can't
push the ship any faster no matter how much wind.

- sail power P = sail_area / displacement^(2/3) : (displacement to the 2/3 power)

We ignore units on this, it is just a number we calibrate it by taking a sample boat - 40 ft long, 25000 pound displacement
450 square feet of sail has P=.52 and reaches hull speed of about 7.5 knots in 15 knots of wind. So we are going to make
the horrible, inexact approximation that

P * wind_speed = boat_speed

Remember that boat_speed <= HS . Wind greater than what it takes to reach hull speed just tilts the boat more.
(the nautical term for tilt is angle of heel, or just heel).

- stability coefficient CSV = beam / cube_root(displacement / 64)

Again, this is just a number. It measures how easy it is for the wind to flip the boat over (capsize is the nautical term)
CSV > 2 is too stable - if the boat capsizes it will stay stay upside down.
CSV < 1.5 is too likely to capsize in a light wind, is considered unsafe
Your class should reject a boat with CSV outside the range 2-1.5

In a later iteration on this class, we may replace this yes/no result with a function that says how likely the boat is
to capsize with a given wind speed.

Performance calculation:

Sailboats can sail somewhat agains the wind -
upwind_angle=45 // a modern triangle rig can sail this much into the wind
upwind_angle=10 // a square rig can sail this much into the wind.

- Ship direction is:

double course // a value between 0 and 360 degrees - where 0 and 360 are the same course

- Wind direction is:

double wind_angle // also a value between 0 and 360 degrees

We will define wind_angle as the direction into which the wind blows (this is opposite to the normal definition
in which we give the direction the wind is coming from, makes calculation easier to visualize)

- boat_speed : to calculate speed for different angles:

If absolute_value( wind_angle - course ) <= 95 // double boat_speed=P*wind_speed
If absolute_value( wind_angle - course ) > 95 and <= 90+upwind_angle // boat_speed=P*wind_speed/2
If absolute_value( wind_angle - course ) > 90+upwind_angle // ship can't sail in that direction
// it has to zig-zag upwind (called "tacking")


Later we may refine this with boat_speed = some function of angle

- safety check:

given hull speed HS, the fastest useful wind UW = HS/P, that is the wind speed needed to drive the boat
as fast as it can go. We will assume that wind_speed > UW is unsafe and we have to drop the sails and
just sit until the wind comes down.

You need to write the class definition and functions to do all the above, then write a program that lets you enter
boat parameters, and then check performance by entering wind_speed, wind_angle and course and the program should
tell you either how fast the boat will go on that course, whether you can sail that course at all, and
if the wind is too strong for safety. Try this with boats of different sizes, beams, weights and sail areas
and see if results seem to make sense or not.

Please note that this is not a homework site. We won't do your homework for you. The purpose of homework is that you learn by doing. However we are always willing to help solve problems you encountered, correct mistakes you made in your code and answer your questions.

We didn't see your attempts to solve this problem yourself and so we cannot correct mistakes you didn't made and answer questions you didn't ask. To get help you should do something yourself and get real problems with something. If your problem is "I don't understand a thing", then you should go back to basics and study again.

Krulcifer Einfolk
Topic archived. No new replies allowed.