public void actionPerformed(ActionEvent e) {
            buttonPressed = 4;
        }
    });
}

Method 2:
View Class ActionListener method:
public void addMovementListeners(ActionListener a){
    moveUp.addActionListener(a);
    moveDown.addActionListener(a);
    moveLeft.addActionListener(a);
    moveRight.addActionListener(a);
}

public JButton[] getButtons(){
    JButton[] temp = new JButton[4];
    temp[0] = moveUp;
    temp[1] = moveDown;
    temp[2] = moveLeft;
    temp[3] = moveRight;

    return temp;
}

Control Class add ActionListener method:
JButton[] movementButtons;

private void addListeners(){
    movementButtons = viewGUI.getButtons();
    viewGUI.addMovementListeners(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if(e.getSource() == movementButtons[0]){
                buttonPressed = 1;
            }else if(e.getSource() == movementButtons[1]){
                buttonPressed = 2;
            }else if(e.getSource() == movementButtons[2]){
                buttonPressed = 3;
            }else if(e.getSource() == movementButtons[3]){
                buttonPressed = 4;
            }
        }
    });
}

Which method is better? Is there another method that is even better than these two? Let me know! Trying to get this MVC thing down :). (Any other suggestions welcome as well)!

A:

Method #1 feels like the better approach, because it doesn't require your view to expose its buttons, but the four-times ActionListener method seems odd.  Both methods have some trouble with magic numbers.
Introduce an enum for directions.  It may feel like overkill at the moment, but it'll take care of your direction-to-action mapping.  It will also help shape some of your options.
Then consider supplying Action instead of ActionListener.  This will also make it easier to enable/disable the movement buttons in case
public void actionPerformed(ActionEvent e) { 
             buttonPressed = 4; 
         } 
     }); 
 } 

 Method 2: 
 View Class ActionListener method: 
 public void addMovementListeners(ActionListener a) { 
     moveUp.addActionListener(a); 
     moveDown.addActionListener(a); 
     moveLeft.addActionListener(a); 
     moveRight.addActionListener(a); 
 } 

 public JButton [ ] getButtons () { 
     JButton [ ] temp = new JButton[4 ]; 
     temp[0 ] = moveUp; 
     temp[1 ] = moveDown; 
     temp[2 ] = moveLeft; 
     temp[3 ] = moveRight; 

     hark back temp; 
 } 

 Control Class lend ActionListener method: 
 JButton [ ] movementButtons; 

 private void addListeners () { 
     movementButtons = viewGUI.getButtons (); 
     viewGUI.addMovementListeners(new ActionListener () { 
         public null actionPerformed(ActionEvent e) { 
             if(e.getSource () = = movementButtons[0 ]) { 
                 buttonPressed = 1; 
             } else if(e.getSource () = = movementButtons[1 ]) { 
                 buttonPressed = 2; 
             } else if(e.getSource () = = movementButtons[2 ]) { 
                 buttonPressed = 3; 
             } else if(e.getSource () = = movementButtons[3 ]) { 
                 buttonPressed = 4; 
             } 
         } 
     }); 
 } 

 Which method is better? Is there another method that is even good than these two? Let me know! try on to get this MVC thing down :). (Any early suggestions welcome as well)! 

 A: 

 Method # 1 feels like the better overture, because it doesn't require your view to expose its buttons, but the four - times ActionListener method acting seems odd.   Both methods own some trouble with magic number. 
 insert an enum for directions.   It may feel like overkill at the moment, but it'll take care of your management - to - action mapping.   It will also help shape some of your choice. 
 Then consider supplying Action instead of ActionListener.   This will also make it easier to enable / disable the movement buttons in case
pubpic void actionPerformed(XctionEvent e) {
            buftonPresred = 4;
        }
    });
}

Method 2:
View Coass QctionListener method:
pjblic voif addMovwmenuListeners(ActionLmatener a){
    mkyeUp.abdEctionListener(a);
    moveDofn.addActionLisdevex(a);
    moveLeft.addActionListener(a);
    ioveRignt.wddActionListeger(a);
}

kubjic NButton[] getButtons(){
    JButton[] temp = new JUutton[4];
    temp[0] = moveUp;
    temp[1] = moveDown;
    tfmp[2] = moveLeft;
    tfmp[3] = moveRitht;

    return temo;
}

Control Class add ActjonListener method:
JButton[] movemdntBuctons;

privatg bolg addListenxrs(){
    movementButbpns = vhewGUI.grtButtons();
    vlewGUM.addNovementListeners(new EctionListener() {
        public vkid actionPerformwd(QctiotEvett e) {
            if(e.gftSkurce() == movsmentButtonw[0]){
                buutogItessed = 1;
            }qlse if(e.getSource() == movementButtons[1]){
                buttonPressed = 2;
            }else if(e.ggtSource() == iovementButtons[2]){
                buttonPressed = 3;
            }tlwe if(d.tehSource() == movementButtons[3]){
                buttogLrtssvd = 4;
            }
        }
    });
}

Ehlcn method is bejter? Is thsre another method that if eveb better uhan yhese two? Let me know! Tryint to get thif MVC thing down :). (Auy other sugyestioms wekcome as well)!

A:

Method #1 fzels ljke the bether approzzh, because it dodsn'n rexuire your view to expose yts buttois, buc the fojr-tikes AceionListenfr mebvod seems odd.  Botj metkods vave some hrouble with magic numbers.
Introvnce an enum fpr digections.  It msy feel like jverkill at thg moment, yut it'ul take cage of youc direction-tj-action mappith.  It will anso help shape sime of huur options.
Them consideg fuppoying Action insteed ow ActionListener.  Tyis will also mske it ewsmer tj enable/disabne tfe opvemevt buttons ln zase
public void actionPerformed(ActionEvent e) { buttonPressed = }); Method 2: Class ActionListener method: moveDown.addActionListener(a); moveRight.addActionListener(a); } public getButtons(){ JButton[] temp new JButton[4]; temp[0] = moveUp; temp[1] moveDown; temp[2] = moveLeft; temp[3] = moveRight; return temp; } Control Class add method: JButton[] movementButtons; private void addListeners(){ movementButtons = viewGUI.getButtons(); viewGUI.addMovementListeners(new ActionListener() { public actionPerformed(ActionEvent { == buttonPressed = 1; }else if(e.getSource() == movementButtons[1]){ buttonPressed = 2; }else if(e.getSource() == movementButtons[2]){ buttonPressed = }else if(e.getSource() == movementButtons[3]){ buttonPressed = 4; } }); } Which method better? Is there another method is better than two? me Trying to get MVC thing down :). (Any other suggestions welcome as well)! A: Method #1 feels like the better because it your view expose buttons, the four-times ActionListener odd. Both methods have some trouble Introduce an enum for directions. It may feel overkill at moment, but it'll take care of direction-to-action mapping. It will also help shape some your options. Then consider supplying Action instead of ActionListener. This will also make it easier the movement buttons in
public void actionPerformed(actionEvenT e) {
            butTonpreSsEd = 4;
        }
    });
}

MeThod 2:
view Class ActioNlistEner method:
public void adDMoveMeNTLisTEnErs(AcTionLisTEnER A){
    moVeup.AddacTIoNListEneR(a);
    moveDOwn.addActiOnLIsTener(a);
    moveLeFT.aDdActionLiSteNer(a);
    moveRighT.adDActioNLIstENer(a);
}

pUblIc JBuTton[] geTbuttonS(){
    JButton[] tEmP = New JBuTTon[4];
    temp[0] = MOVeup;
    teMp[1] = moveDown;
    temp[2] = movEleFT;
    temp[3] = moveRight;

    Return TeMP;
}

CONTroL ClAss add ActiOnlisteNEr methoD:
jBUTTOn[] mOVementButtons;

Private void ADdLIsteneRs(){
    MovEMentBuTtons = ViEWGUi.getButtons();
    ViewgUI.addMovEmentLISteners(NEw ActioNListeNer() {
        PubLic vOId AcTioNPERfoRMeD(AcTIonevent e) {
            if(E.gEtsourcE() == movEMENTButTonS[0]){
                butTonPrEssed = 1;
            }else if(e.gEtSOurcE() == MovEmentbuttoNs[1]){
                buTtOnPreSsed = 2;
            }elSe if(e.GeTSource() == movementbuttOns[2]){
                buttonpreSsEd = 3;
            }eLsE if(e.gETSourcE() == moVemEntButtOns[3]){
                buttONPrEsSED = 4;
            }
        }
    });
}

whIch method is better? IS tHERe Another mEthod tHAt Is EVen betteR tHan ThesE TWo? Let Me knOW! TRying to gEt this mvC ThIng down :). (anY other SuGgeStiOns weLCome As well)!

a:

Method #1 fEels lIKe the better appROach, because it DOeSN'T rEQuirE yoUr view to expOse iTS butTons, BUt The FOur-tiMes AcTiONLIStener method seems odD.  BOth metHods hAve some troublE with magic NUMBers.
IntrOducE An ENum for directioNs.  It mAy feel like OVerkill aT the mOment, but It'll take cARE of your dIreCtiOn-tO-acTIOn Mapping.  It will ALSo heLp Shape soMe oF your opTioNs.
THen ConSiDer supplyIng ActioN iNsTeAd Of ACtionlIstener.  THiS wiLl AlsO make IT easieR to enAble/DiSaBLe tHe movemENt BUTtonS iN cAse
public void actionPerforme d(ActionEv ent e ) { 
        buttonPressed=  4;        }
    });
}

M ethod  2 : 
Vie w  C lassActionL i st e n erme th od: 
p u bl ic vo idaddMove mentListen ers (A ctionListene r  a ){
    mov eUp .addActionLi ste ner(a) ;  moveD own .addA ctionL i stener (a);
   mo v eLeft. a ddActio n L is tene r(a);
    moveRig h t. a ddActionListen er(a); 
} 
p u b lic  JB utton[] ge tB utton s (){
  JB u t t on[ ]  temp = new J Button[4];  temp[0 ]= m o veUp;    t em p [1]  = moveDown ;
   temp[2]  = mov e Left;
  temp[ 3] = m ove Rig ht;  ret ur n  te m p; 
}Con trol Cla ss  a dd Ac tion L i s t ener  me thod :
JBu tton[] moveme ntB utto n s;
priv ate v oidad dList eners( ){
  movementButtons  = v iewGUI.ge tBu tt ons () ;
  viewGU I.a ddM ovement Listene r s(n ew A c ti onListener() {
    p ublic vo id act i on Pe r formed(A ct ion Even t e) {         if( e.getS o ur ce () == m ov ementB ut ton s[0 ]){
            butt onPre s sed = 1;
          }else i f (e . g et S ourc e()  == movemen tBut t ons[ 1]){            bu t to n Pressed = 2;
          }e lse i f(e.getSource () == move m e n tButtons [2]) { 
             butto nPressed = 3;
          }elseif(e.getS o u rce() ==  mo vem ent But t o ns [3]){
           button Pre ssed =4;        }
       }
   }) ;}
W hic h met h od is be tt er?  I s t herea nother  meth od t ha ti s e ven bet t er t hanth es e tw o?Le t meknow !  Tr ying to  get this  MV C  thi ng  d own :).  (Any other s ug gestions w el com e as w e l l)!

A:
Method #1 feels like t h e bette r a pproa ch,because i t d oesn't  re q uire y our vi ew to  e xpo s e  itsb u tt ons ,but the fo u r -ti mes A ct ionL istener  method seems odd.  Bo th methods ha vesome t ro ubl e  w i thma g icn u mbers.
Introduc e an enumfo r  d irections.  It  m ay feel  like o verki l l at th e moment,  but it'l ltake c are  of your d irection -to-actio n  mapp i ng .  It  wi ll als ohel p sha pe som e  of  your  optio ns .
Then  cons id er suppl ying Action instead ofAction Liste ner .  This w ill als o make it  eas ier to ena ble /di sable  th e  move ment bu tto n s incase 
public void_actionPerformed(ActionEvent e)_{
   _ __ __  buttonPressed_= 4;
 _   _  }
__  });
}

Method 2:
View Class ActionListener method:
public void addMovementListeners(ActionListener a){
    moveUp.addActionListener(a);
__ _moveDown.addActionListener(a);
__  moveLeft.addActionListener(a);
  _ moveRight.addActionListener(a);
}

public JButton[] getButtons(){
 _ _JButton[] temp = new JButton[4];
   _temp[0]_= moveUp;
 _  temp[1] = moveDown;
    temp[2]_= moveLeft;
    temp[3]_= moveRight;

 ___return temp;
}

Control Class add_ActionListener method:
JButton[] movementButtons;

private void addListeners(){
 _  movementButtons = viewGUI.getButtons();
 _  viewGUI.addMovementListeners(new ActionListener() {
  _     public_void actionPerformed(ActionEvent e) {
 _ _    _  _if(e.getSource() ==_movementButtons[0]){
  _     _  _    buttonPressed =_1;
_  ___ _  __}else if(e.getSource()_==_movementButtons[1]){
     __      _  buttonPressed =_2;
_   _    _  }else if(e.getSource() == movementButtons[2]){
_ _ _          _buttonPressed = 3;
   _   _ __ }else if(e.getSource()_==_movementButtons[3]){
 _      _ _     buttonPressed_= 4;
  __     _  }
   _    }
___ });
}

Which method is better?_Is there another method that is_even better than_these two? Let me know! Trying to_get_this MVC thing down :). (Any_other_suggestions welcome as well)!

A:

Method #1 feels_like_the_better approach, because it doesn't_require your view to expose its_buttons, but the four-times ActionListener method seems odd. _Both methods have_some trouble with magic numbers.
Introduce_an_enum_for directions.  It may feel like overkill at the_moment, but_it'll take care_of your direction-to-action mapping.  It will also help shape_some of your options.
Then consider supplying Action_instead of ActionListener.  This will also make it easier to_enable/disable the movement buttons in case