Import Import Import Class Public Static Void New Double New New
Import Import Import Class Public Static Void New Double New New
Import Import Import Class Public Static Void New Double New New
*; class DrawingPanelTest2{ public static void main(String[] args) { Scanner input = new Scanner(System.in); double pw = input.nextDouble(); myPan panel = new myPan(pw); JFrame application = new JFrame(); application.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); application.add(panel); application.setSize(400, 400); application.setVisible(true); } } class myPan extends JPanel{ public double pow; public tri play[]; public background back; public myPan(double p){ pow = p; back = new background(p); play = new tri[10]; //this is where you create all of your triominoes //you can do it a different way, but this is an //example } public void paintComponent(Graphics g){ super.paintComponent(g); back.paintBackground(g); for(int i = 0; i < play.length; i++){ //paint all of the triominos play[i].paintTri(g); } } } class background{ public double pow; public boolean filled[][]; public background(double p){ pow = p; filled = new boolean[up][across]; //this is if it is filled with a tri //you'll need to figure out a way to set //the filled ones to "true" } public paintBackground(Graphics g){ public void paintComponent(Graphics g){
super.paintComponent(g); double num = Math.pow(2,pow); double across; double up; if(pow % 2 == 0){ //is a square across = Math.pow(num,0.5); up = across; } else{ double x = Math.floor(pow/2); double y = x + 1; across = Math.pow(2,x); up = Math.pow(2,y); } System.out.println(across); System.out.println(up); // // double wid = 400/across; //width of one double hi = 400/up; //height of one double nowX = 0; double nowY = 0; for(int i = 0; i < up; i++){ //top to bottom nowX = 0; for(int j = 0; j < across; j++){ g.setColor(Color.BLACK); g.drawRect((int)nowX, (int)nowY, (int)wid, (int)hi); if(...the square is OK...){ //<--you'll need a way to check this using the "filled" array g.setColor(Color.WHITE); g.fillRect((int)nowX, (int)nowY, (int)wid, (int)hi); } else{//the square is not ok g.setColor(Color.RED); g.fillRect((int)nowX, (int)nowY, (int)wid, (int)hi); } nowX = nowX + wid; } nowY = nowY + hi; } } } } class tri{ public tri(int x, int y, int width, int height){ //initialize all of your values } public paintTri(Graphics g){