Trees and Cabins

Trees and Cabins You will make an applet containing a bunch of trees and a few cabins like the one displayed to the left.

HINT:

public Image makeHouse(){ int w=21; int h=20; int[] pix = new int[w*h]; for(int i = 0; i<w*h; i++){ pix[i]=Color.cyan.getRGB(); } for(int y=0; y<10; y++){ for(int x=11+y*21-y; x<11+y*21+y; x++){ pix[x]=(255<<24)|(150<<16)|(120<<8)|120; } } for(int y=10; y<h; y++){ for(int x=y*21+4; x<y*21+18; x++){ pix[x]=(255<<24)|(120<<16)|(150<<8)|150; } } return createImage(new MemoryImageSource(w,h,pix,0,w)); } public Image makeTree(){ int w=13; int h=24; int[] pix = new int[w*h]; for(int i = 0; i<w*h; i++){ pix[i]=Color.cyan.getRGB(); } for(int y=0; y<h-4; y++){ for(int s=7+y*13-(y%5); s<7+y*13+(y%5)+1; s++){ pix[s]=Color.green.getRGB(); } } return createImage(new MemoryImageSource(w,h,pix,0,w)); } You can try to use this code. Notice the use of the modulus operator inside of the embedded for-loops.