Exercise13_9

Exercise13_9 - int temp = list[card1]; list[card1] =...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ /** * * @author Danielle Green */ import java.awt.*; import javax.swing.*; public class Exercise13_9 extends JFrame { ImageIcon card = new ImageIcon("c:\\book\\image\\card\\"); public Exercise13_9() { setLayout(new GridLayout(1, 3)); int[] list = new int[54]; shuffle(list); } public void shuffle(int[] list) { for (int i = 0; i < list.length; i++) { list[i] = i + 1; } int card1 = (int) (Math.random() * 55 - 1); int card2 = (int) (Math.random() * 55 - 1); int card3 = (int) (Math.random() * 55 - 1);
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: int temp = list[card1]; list[card1] = list[card2]; list[card2] = list[card3]; list[card3] = temp; card = new ImageIcon(&quot;c:\\book\\image\\card\\&quot; + temp + &quot;.png&quot;); for (int i = 0; i &lt; 3; i++) { add(new JLabel(card)); } } public static void main(String args) { JFrame frame = new Exercise13_9(); frame.setTitle(&quot;Card Game&quot;); frame.setSize(450, 200); frame.setLocationRelativeTo(null); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } }...
View Full Document

Ask a homework question - tutors are online