Passing in a DAUNT Faction Type for Daunt Class

In summary, the conversation discussed creating a Daunt class for an enum called Faction, and how to pass in a DAUNT faction type for the Daunt class. It was suggested to add a Faction attribute and getter in the Daunt class in order to retrieve the DAUNT faction type. The return type for the getter would be Faction. The conversation also emphasized the importance of appreciating what is learned in order to continue learning.
  • #1
Robben
166
2

Homework Statement



Suppose I have an enum class named Faction and one of the constants is named DAUNT. I created a Daunt class of the enum but how can I pass in a DAUNT faction type in for Daunt?

Homework Equations



None

The Attempt at a Solution



Code:
public enum Faction {
   ALMIGHTY, AMBITION, DAUNT, RESTLESS, CAN;
}

public class Daunt {

public Daunt() {
}

}
 
Physics news on Phys.org
  • #2
There is no connection between the DAUNT enum and Daunt class other than a similarity in the name

As an example, you could add a
Java:
Class Daunt {
    Faction myenum = Faction.DAUNT;
    ...
}
as an attribute in the Daunt class and a getter to retrieve it.
 
  • #3
jedishrfu said:
There is no connection between the DAUNT enum and Daunt class other than a similarity in the name

As an example, you could add a
Java:
Class Daunt {
    Faction myenum = Faction.DAUNT;
    ...
}
as an attribute in the Daunt class and a getter to retrieve it.

I see so then in order to retrieve it I will do

Java:
public getMyenum() {
    return myenum;
}
 
  • #5
jedishrfu said:
Yes that's one way.

What will the value of the return type of myenum be? Will it have no value? For example, I won't have to declare int or String into my getter, i.e. public int getMyenum()?
 
  • #6
Actually, I figured it out. It will be Faction. Thank you very much! I should have never majored in math and should have majored in CS.
 
  • #7
Nah math is cool too.

Always appreciate what you learn because it will help you learn more.
 
  • Like
Likes Robben
  • #8
@Robben, you need to include the return type (Faction) in your definition of getMyenum.

Java:
public Faction getMyenum() {
    return myenum;
}
 
  • #9
Mark44 said:
@Robben, you need to include the return type (Faction) in your definition of getMyenum.

Java:
public Faction getMyenum() {
    return myenum;
}

Understood. Thank you!
 

FAQ: Passing in a DAUNT Faction Type for Daunt Class

What is a DAUNT Faction Type?

A DAUNT Faction Type refers to a specific personality trait or characteristic that determines a person's placement in the Daunt Class. These types are based on the virtues of bravery, courage, and strength.

How are DAUNT Faction Types determined?

DAUNT Faction Types are determined through a combination of personality tests and evaluations. These tests assess a person's beliefs, values, and actions to determine which type they best align with.

Can a person have multiple DAUNT Faction Types?

No, a person can only have one DAUNT Faction Type. This is because each type represents a distinct set of traits and characteristics that cannot coexist within a single individual.

What are the different DAUNT Faction Types?

The five DAUNT Faction Types are Courageous, Intrepid, Valiant, Fearless, and Audacious. Each type represents a different aspect of bravery and courage, and individuals may exhibit different levels of these traits within their chosen type.

How does a person's DAUNT Faction Type affect their role in the Daunt Class?

A person's DAUNT Faction Type does not determine their specific role in the Daunt Class. Instead, it is used to assess their strengths and weaknesses and help them develop their skills and abilities within the class. All DAUNT Faction Types are valued and respected within the Daunt Class.

Similar threads

Replies
14
Views
2K
Replies
1
Views
2K
Replies
1
Views
2K
Replies
1
Views
1K
Back
Top