班级里的班级?或其他东西
我的老师在本周的实验中为我提供了这一点代码来帮助我,遗憾的是它有一点帮助,但还不够。在上下文中,我在“selectedType”中,我不确定,这不是我在这里的原因。我来这里是因为我想知道是否有人可以解释“Airplane.Type.Fighter”是什么。 飞机是与此相关的一类。但我不确定 Type 是否是另一个应该位于 Airplane 内部的类。
想法?
switch (selectedType)
{
case Airplane.Type.Fighter:
newPlane = new FighterJet(name, position, cboPlaneType.SelectedItem);
break;
case Airplane.Type.Passenger:
int numPassengers = Utilities.getIntegerInputValue(txtNumberPassengers);
newPlane =
new PassengerAirplane(name, position, txtType.Text, txtFlightNumber.Text, numPassengers);
break;
default:
newPlane = new Airplane(name, position);
break;
}
I was given this little bit of code by my teacher for this weeks lab to help out and sadly it helps a bit but just not enough. In the context im in "selectedType" i'm not sure about and that's not why i'm here. I'm here because I wanna know if someone can explain what "Airplane.Type.Fighter" could be.
Airplane is a class connected to this one. But i'm not sure if Type is another class that should be inside of Airplane or not.
Thoughts?
switch (selectedType)
{
case Airplane.Type.Fighter:
newPlane = new FighterJet(name, position, cboPlaneType.SelectedItem);
break;
case Airplane.Type.Passenger:
int numPassengers = Utilities.getIntegerInputValue(txtNumberPassengers);
newPlane =
new PassengerAirplane(name, position, txtType.Text, txtFlightNumber.Text, numPassengers);
break;
default:
newPlane = new Airplane(name, position);
break;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
好吧,我们只能在这里猜测。我的猜测是 Airplane 是当前类的属性,而
Airplane.Type
是 枚举,其值例如FighterJet
和Passenger
。正如肖恩在评论中指出的那样,这很可能是一个内部枚举。
Well, we can only guess here. My guess is that Airplane is a property of the current class and that
Airplane.Type
is an enumeration with values such asFighterJet
andPassenger
.As sean pointed out in the comments, it's a good chance that it's an inner enumeration.
看起来它可能是一个
enum
It looks like it's probably an
enum
你需要在这里写下飞机的定义,才能得到答案。
此信息不足以提供答案。
You need to write the definitions of Airplane here, to get an answer.
This information is insufficient for an answer.
它可以是 Class.Enum.EnumType 也可以是 Class.Class.Const
It could be a Class.Enum.EnumType or it can be Class.Class.Const
如果您查看
Airplane
类的定义,就很容易找到答案。另外,selectedType
的类型应该给您一个指示。如果您没有源代码,如果您右键单击Airplane.Type.Passenger
(例如)并选择“转到定义”,Visual Studio 可以为您生成类大纲。另外,您还可以使用 Reflector 之类的工具来查看代码。但是,它似乎是一个嵌套枚举(最明显的选择):
但它也可以是带有常量的嵌套类型:
It's easy to find out if you look at the definition of the
Airplane
class. Also, the type ofselectedType
should give you an indication. If you don't have the source code, Visual Studio can generate a class outline for you if you right click onAirplane.Type.Passenger
(for example) and choose "Go To Definition". Also, you can use a tool like Reflector to look at the code.But, it seems it's a nested enum (the most obvious choice):
But it can also be a nested type with constants: