Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I just realized I was suppose to create a GUI program that create 3 to 5 instanc

ID: 3670166 • Letter: I

Question

I just realized I was suppose to create a GUI program that

create 3 to 5 instances of the shirt class in the main program of the shirtDemo class and populate each of the instances properties using simple assignment.

create a Method named Display in the shirtDemo class that takes a variable number of arguments using a parameter array.

        Loop through the parameter array displaying the properties from each shirt object in the array.

Call the Display method a few times using a different number of shirt objects each time to verify that the method handles them properly.

This is what I orginally had until I found out it had to be a GUI

using System;

namespace ShirtDemo
{
class Program
{

public string material { get; set; }
public string color { get; set; }
public string size { get; set; }

static void Main(string[] args)
{
  

Shirt[] array1 = new Shirt[3];
array1[0] = new Shirt("Cotton", "pink", "small");
array1[1] = new Shirt("Polyester", "red", "medium");
array1[2] = new Shirt("Silk", "blue", "large");

DisplayStrings(array1);
}

private static void DisplayStrings(Shirt[] array1)
{
throw new NotImplementedException();
}

// params array method
public static void DisplayString(params Shirt[] array)
{
foreach (Shirt x in array)
{
Console.WriteLine("Material is:" + x.material);
Console.WriteLine("Color is:" + x.color);
Console.WriteLine("Size is:" + x.size);
Console.WriteLine("---------------------------------------");

Explanation / Answer

you are no need to write gui programm.

look at the java programme for the given problem.

save the java programme with "Shirts.java" and run it for the required output.

------------------------------------------------------------
public class Shirts {

String material,color,size;
Shirts(String material1,String color1,String size1)
{
this.material=material1;
this.color=color1;
this.size=size1;
}
  
public static void main(String args[])
{
Shirts[] shr=new Shirts[3];
shr[0]=new Shirts("cotton","pink","small");
shr[1]=new Shirts("Polyester", "red", "medium");
shr[2]=new Shirts("Silk", "blue", "large");
displayProp(shr);
}
  
static void displayProp(Shirts[] shr)
{
for(int i=0;i<shr.length;i++)
{
System.out.println("Properties of "+(i+1)+" shirt");
System.out.println(shr[i].material);
System.out.println(shr[i].color);
System.out.println(shr[i].size);
}
}
  
}

----------------------------------