0

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;
  }
Oded
  • 489,969
  • 99
  • 883
  • 1,009
David Brewer
  • 1,864
  • 8
  • 25
  • 37

6 Answers6

4

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 as FighterJet and Passenger.

As sean pointed out in the comments, it's a good chance that it's an inner enumeration.

alexn
  • 57,867
  • 14
  • 111
  • 145
  • 1
    No, `Airplane` is not a property, it's clearly a class. But here we see the problems with letting the non-expert asking the question pick the "best" answer. – Ben Voigt Feb 04 '11 at 17:37
  • It can very well be a property. The only thing indicating it's a class is the `new Airplane` part, but the property can very well be named Airplane. – alexn Feb 04 '11 at 17:39
  • No, it cannot be a property. If it were, it wouldn't work in the case statement. – Pedro Feb 04 '11 at 19:09
  • Yep, you're actually right. Missed that one. You shouldn't be on SO this late :) – alexn Feb 04 '11 at 22:30
2
public class Airplane
{
    public enum Type
    {
        Fighter,
        Passenger
    }
}
Pedro
  • 382
  • 2
  • 7
1

It looks like it's probably an enum

Ben Voigt
  • 277,958
  • 43
  • 419
  • 720
1

You need to write the definitions of Airplane here, to get an answer. This information is insufficient for an answer.

manishKungwani
  • 925
  • 1
  • 12
  • 44
1

It could be a Class.Enum.EnumType or it can be Class.Class.Const

Alex Mendez
  • 5,120
  • 1
  • 25
  • 23
1

It's easy to find out if you look at the definition of the Airplane class. Also, the type of selectedType 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 on Airplane.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):

class Airplane {
  public enum Type {
    Fighter,
    Passenger
  }
}

But it can also be a nested type with constants:

class Airplane {
  public static class Type {
    public const string Fighter = "Fighter";
    public const string Passenger = "Passenger";
  }
}
Jordão
  • 55,340
  • 13
  • 112
  • 144