我是新手,我不知道该怎么做,我完全被困住了!
我已经创建了亚美尼亚国旗,而且行很容易。
如果我想将代码更改为水平的(或类似于带有红色、白色和绿色的意大利国旗),我将如何对其进行编码?
这就是我做亚美尼亚国旗的方式:
import java.awt.Color;
/**
* A program to draw an Armenian flag.
*
* @author O
* @version 5
*/
public class ArmenianFlag
{
public static void main(String[] args)
{
// the flag has three bands of colour
// and the aspect ratio is 1:2 (it's twice as wide as it is high)
int WIDTH = 6;
int HEIGHT = 3;
int CELL_SIZE= 60;
// Mix up the right colours
Color RED = Color.RED;
Color BLUE = new Color(0, 0, 170);
Color ORANGE = new Color(255, 153, 0);
// Create the window to display in
FlagFrame frame = new FlagFrame("Armenia", HEIGHT, WIDTH, CELL_SIZE);
// OK - now we are ready to paint the colours in the right places
for(int row = 0; row < HEIGHT; row++)
{
for(int col = 0; col < WIDTH; col++)
{
switch(row)
{
case 0:
frame.selectColor(row, col, RED);
break;
case 1:
frame.selectColor(row, col, BLUE);
break;
case 2:
frame.selectColor(row, col, ORANGE);
break;
}
}
}
}
}