Is it OK to have no constant fields in an enum type?

Hello!

I was wondering if it is good or bad to have no constant fields in the enum types (which would be modified during execution of the program)
My question is if it goes against the semantics and idioms.

Here is an example of what I want to do:
public enum ChessPieceColor {

    BLACK,
    WHITE;

    // Reference to the player who plays the given color
    private Player player;

    public void setPlayer(Player player) {

        this.player = player;

    }

    public Player getPlayer() {

        return player;

    }

}
It would be a game of chess, where the chess pieces would be a color based on the enum. And if I want to know which player plays a certain color, I can do: ChessPieceColor.BLACK.getPlayer)

It is an important work at home so I would have someone's opinion whether or not it is an acceptable design.

I hope someone can help
Thank you very much!

Personally, I don't think it's a good idea.

Your statement implies somewhat that a player is member of BLACK and BLACK is a member of ChessPeiceColor, that sounds wrong.
ChessPieceColor.BLACK.getPlayer)

Also, in the light of the foregoing, when I see a term all in capitals as the BLACK, I think of it, which represents a constant by convention and therefore has functions.

What about using:
A player = ChessBoard.getPlayer (ChessPieceColor.BLACK);
That said, only a chess board has a player who plays the BLACK position.
(Note: when the player is instansiated, it must store as a variable what position his reading: black or white)

Tags: Java

Similar Questions

  • I want to draw a waveform where I have a constant slope (defined by me) and new data are plotted on the graph with the slope defined already in the background.

    I want my table to have a constant slope already mapped out before she continues start tracing data in real-time... so that I can compare my new data point to point with the ideal slope that I already have in the background

    Hi raza,.

    as I said: it is not a problem to have two plots on a graph. But you need to use a graphic instead of a chart!

    Like this:

    have a constant ground created before the loop and a variable field created in the loop!

  • Firefox has crashed, and now I have a constant stream of blank tabs that keep popping up in front of all the others. They will not erase.

    First all the tabs I had open suddenly lacking at the Firefox help page. Now I have a constant stream of blank tabs that keep popping up in front of others. I click again to remove the but they back just pop up. Also whenever I delete a tab while browsing a Web site, I get another white added to the front of all the others. I uninstalled and reinstalled the program and it did not help.

    You ensure that you do not have a problem with a sticky key F1 on your keyboard?

    Start Firefox in Firefox to solve the issues in Safe Mode to check if one of the Add-ons is the cause of the problem (switch to the DEFAULT theme: Tools > Modules > themes).

    • Makes no changes on the start safe mode window.

    See:

    If this does not work in mode without failure, then disable all extensions and then try to find out who is the cause by allowing both the problem reappears.

    • Choose "Disable all add-ons" on issues to troubleshoot Firefox in Safe Mode to set window to disable all extensions.
    • Close and restart Firefox after each change through "file > exit ' (Mac: ' Firefox > leave";) Linux: "file > exit ')

    If this does not help then try a new profile.

    See basic troubleshooting: a new profile

    Your above posted the details of the system tampon() obsolete show with known risks to stability and security that you should update.

    1. Shockwave Flash 10.1 r53
    2. Next-generation Java plug-in 1.6.0_14 for Mozilla browsers

    Update the Flash plugin to the latest version.

    Update the Java plugin to the latest version.

  • I'm looking to have an input field with the search button, search button click the search button below the search results to display. How can I do?

    I'm looking to have an input field with the search button, search button click the search button below the search results to display. How can I do?

    Hello

    998765 wrote:

    You are right

    Please pass by the database 2 day + Application Express Developer's Guide

    Check this code example

    1 create a text field element I say P1_INPUT_FIELD

    2. create a button

    Name of the button: search

    Action: Send the page

    3. change your report query and where clause to your query below

    It will search on ename and empno, in this way, you can add more columns

    SELECT EMPNO
               , ENAME
               , SAL
               , MGR
               , COMM
      FROM EMP
    WHERE TRIM(UPPER(ENAME)) like '%' || TRIM(UPPER(:P1_INPUT_FIELD)) || '%'
           OR TRIM(UPPER(EMPNO)) like '%' || TRIM(UPPER(:P1_INPUT_FIELD)) || '%'
    

    4. we find the source of the region-> page article to submit-> P1_INPUT_FIELD

    Hope this helps you,

    Kind regards

    Jitendra

  • I have a text field. I need to remove the first 8 characters of the field, leaving the remaining characters. Help?

    I have a text field. I need to remove the first 8 characters of the field, leaving the remaining characters. Help?

    Example:

    Text Example.JPG

    I need to remove these numbers PXXXXXX. Leaving the other characters.

    Thank you

    Bob

    A normal 'substring' is what you're looking for.

    For a formula of the column in the response criteria tab:

    SUBSTRING ("YourPresTable". "YourPresColumn" OF 9)

    To make the RPD and the workload of shipping off the coast to the database rather than forcing the work on the server of the OBI or presentation:

    Substring ("01 - Sample App Data (ORCL)" ".." ") "" "BISAMPLE '." " D10 product (dynamic table)". ("' Prod_Dsc ' 9)

  • I have two text fields, where the user will sign a text field and the other text field should be mandatory

    I have 2 text fields, and how can I do a condition when the text 1 field is entered, then they must enter data into the text field 2.  I know it seemed simple, but I'm just a beginner in this... Thanks in advance!

    Hello

    I'm sorry, I forgot this matter.

    Please try this code...

    If (this.isNull)

    {

    TextField2.validate.nullTest = 'error ';

    }

    on the other

    {

    TextField2.validate.nullTest = "disabled";

    }

    Hope than that,

    S, candy.

  • When a subclass must have its own fields and when to use its super

    When a subclass must have its own fields and when to use fields of its superclass?


    Hi, thanks for reading this post!

    I would use a specific example to my question.

    public class BankAccount {
         private double accountBalance;
         
         public double getBalance() {
              return this.accountBalance;
         }
    }
    
    public class SavingsAccount extends BankAccount {
         private double accountBalance;
         
         public double getBalance() {
              return this.accountBalance;
         }
    }
    In the example of bank account, account Bank both SavingsAccount will have a getBalance() method. As a result, they
    both need an account balance field. My question is as getBalance() for both classes will occur exactly the same
    operation, when I should omit declaring the getBalance() method and the accountBalance in the subclass field, and
    When should I include them?

    My own thought is when we never instantiate a superclass object (for example, an abstract class), then we place
    common fields in the superclass abstract and subclasses have access to these areas via getter/Setter protected
    access the fields of the superclass. This is the principle of reuse.

    But if you do not need to instantiate a superclass and the superclass needs to maintain its own fields, then
    I would need to replicate the getBalance() accountBalance and field method in the subclass.

    Is my thinking correct or incorrect?

    Thank you in advance for your help!

    Eric

    Published by: er * August 22, 2011 20:19

    ER * wrote:
    If SavingsAccount inherits BankAccount.getBalance ()... getBalance () would return accountBalance bank account. This isn't the right result we want.

    In fact, I think that this is precisely what you want.

    We want getBalance() accountBalance bank account back when we use a BankAccount object and SavingsAccount accountBalance when we use a SavingsAccount object.

    I seriously doubt that. I think you are confused a bank account with a customer, who may have multiple accounts.

    In all the systems I've ever seen, a SavingsAccount IS - A BankAccount - that is to say, it is a subtype of real. Now, it can contain many other areas ('interest'?), that a normal account would not be 'balance' is not one of them.

    Winston

  • Can we have text search fields

    Can we have text search fields in OBIEE dashboards. If Yes is it we can filter the report based on the text specified in the search fields.

    In my case

    I have a report which my report has multiple records for each day. Can the professional user specify the date range to filter the report on the dashboard?

    Hi Tintin,
    Inside of your report of responses make sure you that your Date column has a filter that "is"get ".
    Create a dashboard and add the same Date column in the same catalogue presentation. Operator menu drop-down of the Date column, select "is between" and to the drop-down list control, select "calendar". Save the results.
    Add both on the same page of dashboard and the user will be able to select records between the dates of beginning and ending on the Date column prompted.

    Hope this helps,
    J

  • How to make a list of question field with the data type DATE?

    I have a column with the DATE data type. Using forms 6i I want to generate a poplist field of list item with this column while the value of the items in the list of names of days like SATURDAY, SUNDAY, MONDAY. If we change the date to a char data type, it won't work properly, but now with the data type DATE behind him, it gives the following error message

    "FRM-32082: invalid value for given the type of element."
    List WEEKREST
    Article: WEEKREST
    Block: EMPRESTS
    Form: module 3
    FRM-30085: unable to adapt to the shape for the release. »


    Using forms 6i how a list item field type DATE data which may contain names of days?

    Set your date as a hidden field (not shown) column. Create your item list with the names of day of varchar2. Create the list item as a base table field that accepts the values of text in the names of the days. On this area, create a when-validate-item trigger that translated the text into an actual date that it then uses to set the value of the real object of the base table.

  • concatenate the fields of the record type

    Hello

    Is it possible to concatenate the fields of the record type?, example
    declare 
     TYPE customer_sales_rectype IS RECORD
          (campo1 char(3),
          campo2  char(3),
          campo3  char(3));
    
             
      TYPE ZZZ IS RECORD (kkk customer_sales_rectype);
          x customer_sales_rectype;
         
    begin
      x.campo1:='000';
      x.campo2:='aaa';
      x.campo3:='BBB';
    end;
    I have a table
    ID_REPORT NUMBER                                   
    ID_LINE     NUMBER                                  
    DT_FILE  DATE           Y                        
    DS_LINE     VARCHAR2(2048) Y       
    My charly had more than 50 columns and unavoidable to concatenate the columns, example:
    select column001 ,
           ';' PV1,
           COL2,
           COL3
           COL4,
         ';' PV2,....ETC
    FROM MY TABLES
    I think that movement query result in a variable of type record that I would can insert in the table in the column is DS_LINE some transformatcion.

    Is it possible without using COL1 | PV1. COL2. COL3 | COL4 | PV2... etc.


    Thanks in advance
    using 9.2.02

    It's pretty easy to write a function for this. Here's a 'coffee time ': implementation

    create or replace function multi_concat
        (p_args sys.dbms_debug_vc2coll)
        return clob
    as
        rv clob;
    begin
        dbms_lob.createtemporary(rv, TRUE);
        for i in p_args.first .. p_args.last
        loop
            dbms_lob.writeappend(rv, length(p_args(i)), p_args(i));
        end loop;
        return rv;
    end multi_concat;
    /
    

    And the proof of coffee is in the dip of the ring:

    SQL> select multi_concat ( sys.dbms_debug_vc2coll ( ('Red Fish', 'Blue Fish', 1, 'Fish',2,'Fish'))
      2* from dual
    
    MULTI_CONCAT(SYS.DBMS_DEBUG_VC2COLL('REDFISH','BLUEFISH',1,'FISH',2,'FISH'))
    --------------------------------------------------------------------------------
    Red FishBlue Fish1Fish2Fish
    
    SQL> 
    

    I add a member TO_STRING function to your type and use something like the above, implement.

    You can also use the data dictionary to generate a string that connects the attributes of your type with the concatenation operator.

    Cheers, APC

  • I have disabled my iPhone s4 because I type in my password PIN for several times how I unlock now?

    I have disabled my iPhone s4 because I type in my password PIN for several times how I unlock now?

    Follow the instructions in this article to support that best apply to your situation:

    iOS: device disabled

    Good luck

    GB

  • Disable the pop up "you have new applications that can open this type of file.

    Disable the pop up "you have new applications that can open this type of file.

    And HOW do I GET THE BUTTON SUBMIT ON THIS ISSUE at WORK?

    Hello
    The notification will automatically turn off once you open this type of a file several times.
    In addition, if you enable notifications, you can go to:
    Charms bar > settings > Notifications > turn off notifications for... hours.

  • The deleted field name cannot be used for a new field of a different type

    I use Acrobat XI in Windows 7 to create a form.

    A text area field was created and named "XYZ". The form has been saved and closed.

    During an editing session later, the field has been deleted, and the form is saved and closed.

    In another, later editing session, I tried to create a new field box to check named "XYZ". Adobe responded saying that the name was already used for a field of a different type, as well as the name "XYZ" could not be assigned to the field.

    I find no indication that any field that is named "XYZ" exists. How can I work around this dilemma?

    Thank you, George. You gave me an idea of the problem.

    No, the field does not appear in the list of fields.

    In the JS Debugger, your proposed watch returns - 1, and

    getField("XYZ").valueAsString returns the default string that has been put in

    the field of the same name before it is deleted.

    That all means that the field is certainly in the form, but not on any

    page. Guess what? The form has a hidden page template! I think so

    the field is still in the model and that's the problem.

    Great! I made my changes in shape before programming the

    model. Silly me! Thank you very much.

    David

  • How to display sysdate + 1 on the MessageTextInput field with the data type Date

    Hello

    I have a class messageTextInput that the data type Date. I am able to view the sysdate in the area of the messageTextInput, now my requirement is I have to post sysdate + 1. Please let me know how to proceed.

    This is my code:

    TXN OADBTransaction = (OADBTransaction) am.getTransaction ();
    EntryDate date = txn.getCurrentDBDate ();
    System.out.println ("DATEEE > > > > > > > > >" + entryDate);
    masterRow.setAttribute ("EffectiveDate", entryDate);

    Kind regards
    Suresh.

    SELECT double ADD_MONTHS(sysdate,12)

  • I have a constant and reproducible - crash InDesign CC 2014 - Mac OS - Mavericks

    Hi all.  I installed the trial of 30 days of Indesign CC 2014.  I have a reproducible crash that I can't escape.

    Sometimes when I create a text box, or just select the text tool, create a box, and start typing.  It all works very well.  The incident occurs if I click in the box and try to move it.  It crashes every time, without fail.  This does not happen if I use the arrows to move the frame.  Only when I click in the box and try to move it with the mouse.  It's maddening!

    I deleted all preferences, as well as caches of InDesign, etc. in ~ library (by another recommendation) that did not help.

    Here is the crash log... Help, please!

    Process: Adobe InDesign CC 2014 [50848]

    Path: / Applications/Adobe InDesign 2014/Adobe InDesign 2014.app/Contents/MacOS/Adobe InDesign 2014 CC CC CC

    ID: com.adobe.InDesign

    Version: 10.0.0.70 (10000)

    Code type: X 86-64 (Native)

    Parent process: launchd [162]

    Responsible for: Adobe InDesign CC 2014 [50848]

    User ID: 501

    Date/time: 2014-07-10 07:29:51.030-0500

    OS version: Mac OS X 10.9.3 (13 D 65)

    Report Version: 11

    Crashed thread: 0 dispatch queue: com.apple.main - wire

    Exception type: EXC_BAD_ACCESS (SIGSEGV)

    Exception codes: KERN_INVALID_ADDRESS at 0x00007fa80001d023

    VM regions near 0x7fa80001d023:

    MALLOC_NANO-0000608001400000-0000608003800000 [36.0m*] rw-/ rwx SM = PRV

    ->

    MALLOC_TINY 00007fa8f9c00000-00007fa8fa000000 [4096K] rw-/ rwx SM = PRV

    Thread 0 crashed: Dispatch queue: com.apple.main - wire

    0 com.apple.CoreFoundation 0x00007fff8afe5a80 __CFPasteboardLockTry + 160

    1 com.apple.CoreFoundation 0x00007fff8b060cd6 CFPasteboardBeginGeneration + 70

    2 com.apple.HIServices 0x00007fff8b17aaef PasteboardClear + 33

    3 com.adobe.InDesign.Application UI 0x000000011072a0ee 0x1105e9000 + 1315054

    4 com.adobe.InDesign.Application UI 0x00000001106689db 0x1105e9000 + 522715

    5 com.adobe.InDesign.Layout UI 0000000113525806 x 0 0 x 113429000 + 1034246

    6 com.adobe.InDesign.Layout UI 0x000000011344c00a 0 x 113429000 + 143370

    7 com.adobe.InDesign.Layout UI 0x0000000113438f61 0 x 113429000 + 65377

    8 com.adobe.InDesign.Layout UI 0x0000000113438bfc 0 x 113429000 + 64508

    9 DV_WidgetBinLib.dylib 0x00000001033abedb DVEventHandler::DVPointerEvent (dvaui::ui:UI_Node *, dvaui::ui:PointerEvent const &, bool &) + 315

    10 DV_WidgetBinLib.dylib 0 x 0000000103396303 DVHostedWidgetView::PrivateImpl:PointerEventCallback(dvaui::ui::UI_Node*,_dvaui::ui::PointerEvent_const&,_bool&) + 83

    11 DV_WidgetBinLib.dylib 0x000000010339aed3 0 x 103389000 + 73427

    12 com.adobe.dvaui.framework 0x0000000103fc3792 dvaui::ui:UI_Node:UI_DispatchCustomPointerEventToNode(dvaui::ui::UI_Node*,_boost::intrusive_ptr<dvaui::ui::UI_Node>,_dvaui::ui::PointerEvent_const&,_bool&) + 146

    13 com.adobe.dvaui.framework 0x0000000103fc347a dvaui::ui:UI_Node:UI_DispatchPointerEventToLeaf(dvaui::ui::UI_Node*,_dvaui::ui::UI_Node*,_dvaui::ui::PointerEvent_const&) + 170

    14 com.adobe.dvaui.framework 0x0000000103fc2d60 dvaui::ui::UI_Node::DispatchPointerEvent::operator() (dvaui::ui:UI_Node *, dvaui::ui:UI_Node *, dvacore::geom:PointT < float > const &) const + 128

    15 com.adobe.dvaui.framework 0x0000000103fcac3a std::pair < bool, dvaui::ui:UI_Node * > dvaui::ui:UI_Node:UI_DispatchPointerEventTowardsLeafT < dvaui::ui:UI_Node:DispatchPoint erEvent > (dvaui::ui:UI_Node:DispatchPointerEvent, dvacore::geom:PointT < float > const &, bool) + 154

    16 com.adobe.dvaui.framework 0x0000000103fcac22 std::pair < bool, dvaui::ui:UI_Node * > dvaui::ui:UI_Node:UI_DispatchPointerEventTowardsLeafT < dvaui::ui:UI_Node:DispatchPoint erEvent > (dvaui::ui:UI_Node:DispatchPointerEvent, dvacore::geom:PointT < float > const &, bool) + 130

    17 com.adobe.dvaui.framework 0x0000000103fcac22 std::pair < bool, dvaui::ui:UI_Node * > dvaui::ui:UI_Node:UI_DispatchPointerEventTowardsLeafT < dvaui::ui:UI_Node:DispatchPoint erEvent > (dvaui::ui:UI_Node:DispatchPointerEvent, dvacore::geom:PointT < float > const &, bool) + 130

    18 com.adobe.dvaui.framework 0x0000000103fcac22 std::pair < bool, dvaui::ui:UI_Node * > dvaui::ui:UI_Node:UI_DispatchPointerEventTowardsLeafT < dvaui::ui:UI_Node:DispatchPoint erEvent > (dvaui::ui:UI_Node:DispatchPointerEvent, dvacore::geom:PointT < float > const &, bool) + 130

    19 com.adobe.dvaui.framework 0x0000000103fcac22 std::pair < bool, dvaui::ui:UI_Node * > dvaui::ui:UI_Node:UI_DispatchPointerEventTowardsLeafT < dvaui::ui:UI_Node:DispatchPoint erEvent > (dvaui::ui:UI_Node:DispatchPointerEvent, dvacore::geom:PointT < float > const &, bool) + 130

    20 com.adobe.dvaui.framework 0x0000000103fc1f21 dvaui::ui:UI_Node:UI_DispatchPointerEventTowardsLeaf(dvaui::ui::PointerEvent_const&,_bool) + 65

    21 com.adobe.dvaui.framework 0x0000000103fc15e2 dvaui::ui:UI_Node:UI_DispatchPointerEventToTarget(dvaui::ui::UI_Node*,_dvaui::ui::PointerEvent_const&,_bool) + 194

    22 com.adobe.dvaui.framework 0x0000000103fc1472 dvaui::ui:UI_Node:UI_DispatchPointerEvent(dvaui::ui::PointerEvent_const&,_bool) + 66

    23 com.adobe.dvaui.framework 0x000000010403f560 dvaui::ui:OS_View:UI_DispatchPlatformMouseEvent(dvaui::ui::MouseEvent_const&,_bool) + 608

    24 com.adobe.dvaui.framework 0x000000010403f0de dvaui::ui:OS_View:UI_DispatchPlatformMouseClickEvent(dvaui::ui::OS_Event_const&) + 606

    25 com.adobe.dvaui.framework 0x000000010403d489 dvaui::ui:OS_View:UI_DispatchEvent(dvaui::ui::OS_Event*) + 121

    26 com.adobe.dvaui.framework 0x000000010403d3e6 dvaui::ui:OS_View:UI_HandleOSEvent(dvaui::ui::OS_Event*) + 22

    27 com.adobe.dvaui.framework 0x000000010403eb69 dvaui::ui:OS_View:UI_HandlePlatformEvent(NSEvent*) + 57

    28 com.adobe.dvacore.framework 0x00000001039ee8dc int dvacore::config:ErrorManager:ExecuteFunction < sub > (< vacuum > boost::function0 *, void *) + 28

    29 com.adobe.InDesign.Application UI 0x000000011071ed12 0x1105e9000 + 1269010

    30 com.adobe.dvacore.framework 0x00000001039eea28 Sub dvacore::config:ErrorManager:ExecuteFunctionWithTopLevelExceptionHandler < sub > (boost::f unction0 < sub >, bool *) + 136

    31 com.adobe.dvacore.framework 0x00000001039efdc5 Sub dvacore::config:ExecuteTopLevelFunction < sub > (< vacuum > boost::function0, bool *) + 165

    32 com.adobe.dvaui.framework 0x00000001040499da dvaui::ui::OS_NodeTimerData::RemoveTimer() + 27242

    33 com.apple.AppKit 0x00007fff81dfaa58-[NSWindow sendEvent:] + 11296

    34 com.adobe.owl 0x00000001037ea764 0x1037b3000 + 227172

    35 com.apple.AppKit 0x00007fff81d995d4-[NSApplication sendEvent:] + 2021

    36 com.adobe.dvaui.framework 0x000000010404334b dvaui::ui::OS_NodeTimerData::RemoveTimer() + 987

    37 com.adobe.exo.framework 0x0000000105bc4c25 exo::app:OS_AppBase:SetResetMenuShortcutsOnClose (bool) + 837

    38 DV_WidgetBinLib.dylib 0 x 0000000103418295 0 x 103389000 + 586389

    39 com.adobe.InDesign.Application UI 0x00000001107251df 0x1105e9000 + 1294815

    com.apple.AppKit 40 0x00007fff81be9a19-[NSApplication run] + 646

    41 com.adobe.exo.framework 0x0000000105bc4648 exo::app::OS_AppBase::RunEventLoop() + 56

    42 com.adobe.InDesign.AppFramework 0x00000001104dac03 0x1103c2000 + 1149955

    43 com.adobe.InDesign.AppFramework 0x00000001104d9d0c 0x1103c2000 + 1146124

    44 main 0x000000010334178f com.adobe.InDesign + 303

    45 com.adobe.InDesign 0x00000001033415f4 start + 52

    Post edited by: Peter Spier

    In the future, please put on pastebin.com incident reports and provide a link...

    I don't recognize the signature of the accident, but it's not a bug - it's something to do with your particular configuration. Do you have a font manager? Utilities running in the background?

Maybe you are looking for

  • Satellite A300 - partial keyboard failure

    I have a very unusual problem. some keys on my keyb have stopped working.from top to bottom, these:[0] ['][p] [e][o][-][space] my laptop is a Satellite A300the bios is updated. Is it possible that this is not a hardware problem? Thanks for the help.

  • Why Windows 7 connect to Bose AE2W even if it is coupled?

    Successfully added Bose AE2W and appears in the list of devices Bluetooth in Windows 7. Clicked on the icon of Bose AE2W which opened the Bluetooth Device Control screen. Click the button to connect. Message indicating the configuration of the Blueto

  • BlackBerry Smartphones when OS 6.0 is available for the Bold 9700?

    Does anyone know that Bold 9700 will get 6.0 OS updated in the future?

  • Import audio to host CC

    I've read tutorials, view videos, all. I think I'm doing everything right. BUT.When I drag an MP3 (256 bits/s) of the timeline on the scene, only the first image is populated with audio.Of after the tutorials with audio keyframe extends to the length

  • Integrate a command-line sql in oracle

    Due to licensing issues, we will have to avoid the access to our database of customer production other than the application developed in forms and reports.Do you know if there is an easy way to integrate a command-line sql in a form, using the existi