我做了一个房间类,(它的长度、宽度、高度都是整数)但我想制作 2 个不同的对象(因为 1 个声明的类是 1 个房间,程序会询问用户“你想要多少个房间拥有?”或类似的东西......)
如何从 Room 类制作 2 或 3 个不同的房间?
这是我所拥有的:
using System;
using System.Collections.Generic;
using System.Linq;
namespace Feladatok1_20
{
public class Exercise55TEST
{
public static void exercise()
{
System.Console.WriteLine("How many rooms would you like to work in?");
int numberOfRooms = Int32.Parse(Console.ReadLine());
List<int> room = new List<int>();
for (int i = 0; i < numberOfRooms; i++)
{
System.Console.WriteLine("How long is the room? (length)");
int length = Int32.Parse(Console.ReadLine());
//room.Add(length);
System.Console.WriteLine("How high is the room? (height)");
int height …Run Code Online (Sandbox Code Playgroud) 我想打印出类似这样的东西:图片
到控制台。
我的“ILogger”类中有以下代码:
namespace GameOfChanceSimulator
{
public interface ILogger //public added
{
void Info(string message);
void Errorr(string message);
}
}
Run Code Online (Sandbox Code Playgroud)
但我不知道如何使这个 ILogger 消息变成如图所示的内容...请帮忙!
c# ×2