In: Computer Science
I have uploaded the Images of the code, Typed code and Output of the Code. I have provided explanation using comments (read them for better understanding).
Images of the Code:
Note: If the below code is missing indentation please refer
code Images
Typed Code:
// using System
using System;
// Creating a class named Dishwash
class Dishwash
{
// a public variable named CubicFeet
public double CubicFeet;
// a public string variable named color
public string color;
// A constructor
public Dishwash(double Feets, string color_name)
{
// initializing the values CubicFeet and color
CubicFeet=Feets;
color = color_name;
}
// a public method Washing
public string Washing()
{
// returning the text washing
return "Now washing dishes!";
}
}
// Main class
class main {
// main method
static void Main() {
// creating an array of DishWasher size 3
Dishwash[] dishes = new Dishwash[3];
// initializing the object dishes
dishes[0]=new Dishwash(4,"Red");
// initializing the object dishes
dishes[1]=new Dishwash(5,"White");
// initializing the object dishes
dishes[2]=new Dishwash(3.5,"Green");
// A for loop to display the info
for(int i=0;i<3;i++)
{
// printing Size of Dish
Console.WriteLine("Dish Size : " + dishes[i].CubicFeet + "
CubicFeet ");
// printing Color of Dish
Console.WriteLine("Dish Color : " + dishes[i].color);
// calling the method Washing and printing the returned text
Console.WriteLine(dishes[i].Washing() + "\n");
}
}
}
//code ended here
Output:
If You Have Any Doubts. Please Ask Using Comments.
Have A Great Day!