2.3 Airline Learning Activity

Create the class diagram

Create one class diagram, one object diagram, and one activity diagram in Violet. Use the same Seats array throughout. Copy exact diagram labels from the plain-text markers without typing the markers.

1.Model the following class definitions
Classes to represent
public class Jet
{
    public Seat[,] Seats;
}

public class Seat
{
    public string Number;
    public bool IsOccupied;
}
A Add the classes and their relationship

Create Jet and Seat. In Seat's attributes compartment, enter + Number : string and + IsOccupied : bool. Leave both methods compartments empty.

Create the object diagram
2.Show the same array with two rows and three columns

The following setup occurs inside an existing method. All six array positions hold distinct Seat objects with the values in the table.

Create the seating array
Jet jet = new Jet();
jet.Seats = new Seat[2, 3];
Seat objects and array positions
Array position Object heading Number IsOccupied
[0, 0] seat1A : Seat "1A" true
[0, 1] seat1B : Seat "1B" false
[0, 2] seat1C : Seat "1C" true
[1, 0] seat2A : Seat "2A" false
[1, 1] seat2B : Seat "2B" true
[1, 2] seat2C : Seat "2C" false
A Add the objects, field values, and references

Create jet : Jet and the six Seat objects headed exactly as shown in the table. Each Seat has Number and IsOccupied fields with the listed values.

B Verify the six references

The first index selects the row; the second selects the column. The occupied objects are seat1A : Seat, seat1C : Seat, and seat2B : Seat. Every array position refers to a Seat object.

Create the occupied-seat activity diagram
3.Model this code using the object diagram's seating array

This code continues inside the same method, after all six references and their field values have been assigned as shown in your object diagram.

Count occupied seats
int occupiedSeats = 0;

foreach (Seat seat in jet.Seats)
{
    if (seat.IsOccupied)
    {
        occupiedSeats = occupiedSeats + 1;
    }
}
A Add the initialization, loop, and occupied-seat check

From a start node, add the action occupiedSeats = 0, then a foreach loop node labeled Seat seat in jet.Seats. Label its two outgoing arrows foreach and done.

The foreach arrow leads to a decision labeled seat.IsOccupied?. Its true arrow leads to the action occupiedSeats = occupiedSeats + 1. Its false arrow skips that action.

B Trace the activity with your object diagram

The loop visits all six seats in row order. The count after each visit is 1, 1, 2, 2, 3, 3. Verify that both occupied and unoccupied seats return to the loop, and that occupiedSeats finishes at 3.

Save and submit
4.Save and review all three diagrams

Use Airline 2.3 LastName as the base filename, replacing LastName with your last name. Keep Violet's diagram-type suffix and .violet.html extension. Open each saved file and check its labels, values, connections, and readability. Confirm that all three diagrams use the same Seats array.

A Package the three Violet files

Place the class, object, and activity diagram files at the ZIP root. Name the archive Airline 2.3 LastName.zip.

5.Submit the ZIP to the matching Airline activity in the Feedback System

Review the feedback, correct your diagrams, save, rebuild the ZIP, and resubmit as needed.

6.Submit the resulting feedback URL to the matching Canvas assignment

Keep your editable Violet files for later work.