これはenmusを使用する良いケースですか? 配列を使用する方が良いでしょうか? ここの値は年に1回と言われることはありません。これはEnumsの正しい使用ですか?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
public enum transmission
{
Manual,
NonSynchronous,
Automatic,
SemiAutomatic,
Continuously,
Infinitely,
Electric,
Hydrostatic,
Hydrodynamic,
}
public enum bodystyle
{
Convertable,
Hatchback,
Sports,
Sedan
}
public enum carcolors
{
Red,
Blue,
Yellow,
White,
Black,
Green
}
public enum fueltype
{
Biofuels,
FossilFuels,
Nuclear,
Fission,
Fusion
}
public class Car
{
public Car(String cName, double cMaxSpeed, String cTransmission, String cBodystyle, String cColors, String cFueltype) {
carname = cName;
transmission = cTransmission;
bodystyle = cBodystyle;
colors = cColors;
fueltype = cFueltype;
maxspeed = cMaxSpeed;
}
public string carname
{
get;
set;
}
public string transmission
{
get;
private set;
}
public string bodystyle
{
get;
private set;
}
public string colors
{
get;
private set;
}
public string fueltype
{
get;
private set;
}
public void carInfo()
{
Console.WriteLine("------------------------------------");
Console.WriteLine("Car Name: " + this.carname);
Console.WriteLine("Car Transmission: " + this.transmission);
Console.WriteLine("Car Bodystyle: " + this.bodystyle);
Console.WriteLine("Car Colors: " + this.colors);
Console.WriteLine("Car Fueltype: " + this.fueltype);
Console.WriteLine("Car MaxSpeed: " + this.maxspeed);
Console.WriteLine("------------------------------------");
}
}
public class Program
{
static void Main(string[] args)
{
Car nissan = new Car("Lamborgini", 255, Convert.ToString(transmission.Automatic), Convert.ToString(bodystyle.Sports), Convert.ToString(carcolors.Red), Convert.ToString(fueltype.Biofuels));
nissan.carInfo();
}
}
}
タイトルをあなたの質問内容と一致させると、回答の質を向上させるのに役立ちます。タイトルは、これが正しい使用法であるかどうかを尋ねます。そうでない場合は、これが最善の行動と対話のリストかどうかを質問します。 –