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.
public class Jet
{
public Seat[,] Seats;
}
public class Seat
{
public string Number;
public bool IsOccupied;
}Create Jet and Seat. In Seat's attributes compartment, enter + Number : string and + IsOccupied : bool. Leave both methods compartments empty.
The following setup occurs inside an existing method. All six array positions hold distinct Seat objects with the values in the table.
Jet jet = new Jet();
jet.Seats = new Seat[2, 3];| 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 |
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.
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.
This code continues inside the same method, after all six references and their field values have been assigned as shown in your object diagram.
int occupiedSeats = 0;
foreach (Seat seat in jet.Seats)
{
if (seat.IsOccupied)
{
occupiedSeats = occupiedSeats + 1;
}
}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.
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.
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.
Place the class, object, and activity diagram files at the ZIP root. Name the archive Airline 2.3 LastName.zip.
Review the feedback, correct your diagrams, save, rebuild the ZIP, and resubmit as needed.
Keep your editable Violet files for later work.