The following shirt-design program is the same as the Shirt program in Figures, except for a slight modification in main :
1 /**************************************************************2 * ShirtDriver.java3 * Dean&Dean4 *5 * This is a driver for the Shirt class.6 **************************************************************/78 public class ShirtDriver9 {10 public static void main(String[] args)11 {12 Shirt shirt1 = new Shirt();13 Shirt shirt2 = new Shirt();1415 System.out.println();16 shirt1.display();17 shirt2.display();18 } // end main19 } // end ShirtDriver1 /************************************************************2 * Shirt.java3 * Dean&Dean4 *5 * This class stores and displays color choices for6 * a sports-uniform shirt.7 ************************************************************/89 import java.util.Scanner;1011 public class Shirt12 {13 private String name; // person’s name14 private String primary; // shirt’s primary color15 private String trim; // shirt’s trim color1617 //*********************************************************1819 public Shirt()20 {21 Scanner stdIn = new Scanner(System.in);22 System.out.print("Enter person's name: ");23 this.name = stdIn.nextLine();2425 this.primary = selectColor("primary");26 this.trim = selectColor("trim");27 } // end constructor2829 //*********************************************************3031 public void display()32 {33 System.out.println(this.name + "'s shirt:\n" +34 this.primary + " with " + this.trim + " trim");35 } // end display3637 //*********************************************************3839 // Helping method prompts for and inputs user’s selection4041 private String selectColor(String colorType)42 {43 Scanner stdIn = new Scanner(System.in);44 String color; // chosen color, first a letter, then word4546 do47 {48 System.out.print("Enter shirt';s " + colorType +49 " color (w, r, y): ");50 color = stdIn.nextLine();51 } while (!color.equals("w") && !color.equals("r") &&52 !color.equals("y"));5354 switch (color)55 {56 case "w":57 color = "white";58 break;59 case "r":60 color = "red";61 break;62 case "y":63 color = "yellow";64 } // end switch6566 return color;67 } // end selectColor68 } // end class Shirt
Trace the above program using either the short form or the long form. To help you get started, here’s the trace setup, including the input. For the short form, you won’t need the line# column.
input
Corneal
r
w
Jill
w
y
ShirtDriver | Shirt | ||||||||||||||
| main |
| Shirt | display | selectColor | obj1 | obj2 |
| |||||||
line# | sh1 | sh2 | line# | this | this | this | cType | color | name | prim | trim | name | prim | trim | output |
Figure ShirtDriver class and associated sample session

Figure Shirt class–part A

Figure Shirt class–part C

We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.