#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2013
    Posts
    4
    Rep Power
    0

    Need help with Assignment


    Hi All,

    I was wondering if anyone could help me with my assignment i have less than a week to hand in my **** n im still nowhere near completing. (I HAVE TO CREATE A SWING BASED MEMORY GAME AND IM STUCK!!!!!!!!!! any kind soul can help me with this????) oh and btw im using eclipse for this assignment

    output should be something like this>>>

    Assignment 1
    Row box for user to enter/ flip up to press-->[__________] flip up
    col -->box for user to enter--> [__________]


    col1 col2 col3 col4 flip all
    row1 ? ? ? ?
    row2 ? ? ? ?
    row3 ? ? ? ?
    row4 ? ? ? ?

    keep playing
  2. #2
  3. Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Aug 2010
    Location
    Eastern Florida
    Posts
    3,713
    Rep Power
    348
    Do you have code that you are having problems with? Post the code and ask some questions about the problems you are having. Be sure to wrap the code in code tags.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2013
    Posts
    4
    Rep Power
    0
    Originally Posted by NormR
    Do you have code that you are having problems with? Post the code and ask some questions about the problems you are having. Be sure to wrap the code in code tags.
    hey bro i manage to create the UI for my assignment so far. Now i just need to know how to create the flip code so tht if i enter a no. under row&col it will flip to give me result. I appreciate if u could help me cheers

    import java.awt.BorderLayout;
    import java.awt.Dimension;
    import java.awt.FlowLayout;
    import java.awt.GridLayout;

    import javax.swing.BorderFactory;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.JTable;
    import javax.swing.JTextField;

    public class Assignment1 {
    public Assignment1() {
    JFrame frame = new JFrame("Assignment 1");
    int exit = JFrame.EXIT_ON_CLOSE;
    frame.setDefaultCloseOperation(exit);

    createMiddlePanel(frame);
    frame.add(createTopPanel(), BorderLayout.SOUTH);

    frame.setLocationRelativeTo(null);
    frame.pack();
    frame.setVisible(true);

    }

    private JPanel createTopPanel() {

    JPanel panel = new JPanel();
    JTable table = new JTable(4, 4) {
    @Override
    public boolean isCellEditable(int row, int column) {
    return false;
    };
    };
    table.setPreferredSize(new Dimension(600, 200));

    for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 4; j++) {
    table.setValueAt("?", i, j);
    }
    }

    table.setValueAt("?", 0, 3);
    panel.add(table);
    return panel;

    }

    private int getInputAsInt() {
    // TODO Auto-generated method stub
    return 0;
    }

    private JPanel createMiddlePanel(JFrame frame) {
    JPanel panel = new JPanel();
    panel.setLayout(new GridLayout(1, 2));
    panel.setBorder(BorderFactory.createTitledBorder("Memory Game"));

    final JLabel label = new JLabel("Row ");
    panel.add(label);

    JTextField text = new JTextField(10);
    panel.add(text);

    frame.add(panel);

    final JLabel label1 = new JLabel("Col");
    JTextField text1 = new JTextField(10);
    panel.setLayout(new FlowLayout(FlowLayout.LEFT));
    panel.add(label1);
    panel.add(text1);

    // Can be use to change or flip tiles
    JButton button = new JButton("Flip Up");
    panel.add(button);

    JButton button1 = new JButton("Flip All");
    panel.add(button1);
    return panel;
    }

    public static void main(String[] args) {
    new Assignment1();
    }

    }
  6. #4
  7. Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Aug 2010
    Location
    Eastern Florida
    Posts
    3,713
    Rep Power
    348
    Please edit your post and wrap the code in code tags:
    [code]
    THE CODE HERE
    [/code]

    if i enter a no. under row&col it will flip to give me result
    Can you describe what "flip" means? Give the numbers that the user would enter and describe what the code will do with those numbers.
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2013
    Posts
    4
    Rep Power
    0
    Originally Posted by NormR
    Please edit your post and wrap the code in code tags:
    [code]
    THE CODE HERE
    [/code]


    Can you describe what "flip" means? Give the numbers that the user would enter and describe what the code will do with those numbers.
    u know how normally a memory game works. in this case the user will need to type a no. between let say 1 to 4 for both col & row. if u can run the code previously i post u will see tht the output have both 4 col and 4 rows so the number enter by user need to match if not it will be error. Once the user click on the flip up button it will prompt the no tht the user enter and flip the ? and reveal the answer.


    so this are my objective for this assignment

    a. identify the swing components used
    b. identify the enum used
    c. create a swing mockup
    d. create suitable java classes
    e. fill up the board with animal tiles
    f. enable a tile to be flipped
    g. check for invalid move
    h. complete the game
    i. debug and test

    Seriously im lost in this programming world. im new at this thing
  10. #6
  11. Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Aug 2010
    Location
    Eastern Florida
    Posts
    3,713
    Rep Power
    348
    Please edit your post and wrap the code in code tags.

    Can you describe what "flip" means in terms of the contents of the rows and columns? If the user enters: row=1 and col=2, what should the program do?
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2013
    Posts
    4
    Rep Power
    0
    [QUOTE=NormR]Please edit your post and wrap the code in code tags.

    Can you describe what "flip" means in terms of the contents of the rows and columns? If the user enters: row=1 and col=2, what should the progr

    Hey can get ur email address so i can sent u an image of my assignment paper. its hard to explain how exactly. lol


    well im gonna try to explain if u can understand roughly how this work when i try to run it. here goes ntg...
    output:

    row [ 1] flip up
    col [ 2]


    col 1 col2 col3 col4
    row1 ? ? ? ?
    row2 ? ? ? ? flip all
    row3 ? ? ? ?
    row4 ? ? ? ?


    after user click flip up:


    col 1 col2 col3 col4
    row1 ? D ? ?
    row2 ? ? ? ? flip all
    row3 ? ? ? ?
    row4 ? ? ? ?

    D IS = DOG , SO IF THE USER ENTER A NO AGAIN LET SAY COL 1 ROW 3

    col 1 col2 col3 col4
    row1 ? D ? ?
    row2 ? ? ? ? flip all
    row3 F ? ? ?
    row4 ? ? ? ?

    F IS = FOX . if the no trigger is not the same animal it will go back to ? like this:

    col 1 col2 col3 col4
    row1 ? ? ? ?
    row2 ? ? ? ? flip all
    row3 ? ? ? ?
    row4 ? ? ? ?

    if user click [flip all] it will reveal all the answer like this;

    col 1 col2 col3 col4
    row1 R C D W
    row2 E C D F flip all
    row3 L R F T
    row4 E L T W


    R= RAT C= CAT D= DOG W= WOLF F= FOX T=TIGER L=LION E=ELEPHANT

    lol i hope this give u a better picture
  14. #8
  15. Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Aug 2010
    Location
    Eastern Florida
    Posts
    3,713
    Rep Power
    348
    Please edit your post and wrap the code in code tags.

IMN logo majestic logo threadwatch logo seochat tools logo