Question
Create an application named ShirtDemo that declares several Shirt objects and includes a display method to which you can pass different numbers of Shirt objects
Create an application named ShirtDemo that declares several Shirt objects and includes a display method to which you can pass different numbers of Shirt objects in successive method calls.
The Shirt class contains auto-implemented properties for a Material, Color, and Size (all of type string).
What I got:
using static System.Console; using System; using System.Collections.Generic; using System.Linq; using System.Text; class ShirtDemo { static void Main(String[] args) { Shirt shirt = new Shirt("cotton", "white", "L"); Console.WriteLine("{0,-12}{1,10}{2,10}", "Material", "Color", "Size"); Display(shirt); shirt = new Shirt("cotton", "blue", "XL"); Display(shirt); shirt = new Shirt("polyester", "pink", "M"); Display(shirt); Console.WriteLine();
Console.WriteLine("{0,-12}{1,10}{2,10}", "Material", "Color", "Size"); shirt = new Shirt("cotton", "white", "L"); Display(shirt); shirt = new Shirt("cotton", "blue", "XL"); Display(shirt); shirt = new Shirt("polyester", "pink", "M"); Display(shirt); shirt = new Shirt("silk", "yellow", "S"); Display(shirt);
Console.WriteLine();
Console.WriteLine("{0,-12}{1,10}{2,10}", "Material", "Color", "Size"); shirt = new Shirt("cotton", "white", "L"); Display(shirt); shirt = new Shirt("cotton", "blue", "XL"); Display(shirt); shirt = new Shirt("polyester", "pink", "M"); Display(shirt); shirt = new Shirt("silk", "yellow", "S"); Display(shirt); shirt = new Shirt("silk", "white", "XXL"); Display(shirt);
Console.ReadKey(); } class Shirt { public string Material { get; set; } public string Color { get; set; } public string Size { get; set; }
public Shirt() { Material = ""; Color = ""; Size = ""; } public Shirt(string material, string color, string size) { this.Material = material; this.Color = color; this.Size = size; } } public static void Display(Shirt shirt) { Console.WriteLine("{0,12}{1,10}{2,10}", shirt.Material, shirt.Color, shirt.Size); }
}
Thank you :)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started