Find Us On: Facebook Twitter Rss Feed Blog
Need To Register? Sign Up Login

MVC Model Java

mariobeka
mariobeka 


What you have to do is described in the pdf file! All the helping classes are also included in the zip file! Attachments Tags Clarifications

Answers

Magic Marbles with MVC

SW_wizard
SW_wizard 



Implemented as per the specifications. Attachments
MagicMarbles_MVC.zip (18 K) Download

Preview
n = Integer.parseInt(scan.nextLine()); return n; } public static void readLine(){ Integer.parseInt(scan.nextLine());

Preview
static void println(Object s){ System.out.println(s); } public static void print(Object x){

Preview
* Width of the field, i.e. the number of columns. * * @return The width of the field. */ public int getWidth(); /** * Height of the field, i.e. the number of rows. * * @return The width of the field.

Preview
field[row][col] = FieldState.EMPTY; if (row > 0) { sum = sum + checkUp(row - 1, col, fs); } if (col > 0) { sum = sum + checkUp(row, col - 1, fs); } if (col < (getWidth() - 1)) {

Preview
return "w"; } }, /** The field is occupied with a black marble. */ BLACK{ public String toString(){ return "b"; } }, /** The field

Preview
be opened. */ RUNNING, /** The game is terminated, i.e., there are no more two equally

Preview
int w= (int)bt.getSize().getWidth(); int h = (int)bt.getSize().getHeight(); int bval = Integer.parseInt(bt.getActionCommand()); row = (bval / (model.getWidth())) + 1; col = (bval % (model.getWidth())) + 1; view.doMove(model, row, col); } } private class newMenuListener implements ActionListener{ @Override

Preview
MagicMarblelistener {

Preview
public static void main(String[] args) { // TODO Auto-generated method stub RunMVC mainRunMVC

Preview
here - so that it happens only once squares = new JButton[model.getWidth()* model.getHeight()]; for(int i=0;i<(model.getWidth()* model.getHeight()); i++){ squares[i] = new JButton(); } updatePanel(); mainframe.setLocationRelativeTo(this); } private void updatePanel(){ JPanel panel1 = new JPanel(); JPanel buttonPanel = new JPanel(new BorderLayout());

Screenshots
Purchase Answer

Additional functionality

SW_wizard
SW_wizard 



used paintComponent to overwrite the panel Attachments
additionalFunctionality.zip (3 K) Download
Preview
public RoundButton(String label) { super(label); Dimension size = getPreferredSize(); size.width = size.height = Math.max(size.width, size.height); setPreferredSize(size); setContentAreaFilled(false); } protected void paintComponent(Graphics g) { g.setColor(getBackground());

Preview
/**to display the playing field in GUI * @param f: Field as already initialized */ public void displayFieldUI(Field f){ mainframe = new JFrame("Magic Marbles"); file = new JMenu("File"); newMenu = new JMenuItem("New Game"); exitMenu = new JMenuItem("Exit"); mpanel2

Screenshots
Purchase Answer