Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create java picture applet that creates simple picture of house, sun, trees and

ID: 3814271 • Letter: C

Question

Create java picture applet that creates simple picture of house, sun, trees and clouds.

Explanation / Answer

import java.awt.Color; import java.util.Random; import appletworld.*; import tester.*; import geometry.*; import colors.*; public class TickyTackApplet extends WorldApplet{ /** Produce a new TickyTackWorld */ public World getNewWorld(){ Cloud cloud = new Cloud(new Posn(200, 100), 90, 60); Sun sun = new Sun(25); return new TickyTack(cloud, sun); } /** Set the size of this world */ public void setWorldSize(){ this.WIDTH = 600; this.HEIGHT = 300; } } class House{ Posn loc; // of the SW corner of the house base int width; // the width of the house int height; // the height of the house Color color; // the color of the house Person person; House(Posn loc, int width, int height, Color color){ this.loc = loc; this.width = width; this.height = height; this.color = color; this.person = new Person(new Posn(this.loc.x + this.width / 2, this.loc.y - this.height / 4), this.width / 2, this.height / 2, this.color); } class Tree{ Posn loc; // the left base of the trunk int trunkHeight; // the height of the trunk int width; // the width of the crown of the tree int height; // the height of the crown of the tree Tree(Posn loc, int trunkHeight, int width, int height){ this.loc = loc; this.trunkHeight = trunkHeight; this.width = width; this.height = height; } class Cloud{ Posn loc; int width; int height; Cloud(Posn loc, int width, int height){ this.loc = loc; this.width = width; this.height = height; } /** move this cloud east with the wind */ void move(int dx){ this.loc.x = this.loc.x + dx; } /** when cloud moves off the canvas, move it back to the west */ void moveInBounds(int dx, int hbound){ if (this.loc.x + dx > hbound) this.loc.x = dx; else this.loc.x = this.loc.x + dx; } class Sun{ int size; // limited to less than 30 Sun(int size){ this.size = size % 30; } /** Class that represents little houses with clouds above */ class TickyTack extends World{ House h1 = new House(new Posn(0, 300), 60, 80, Color.red); House h2 = new House(new Posn(60, 300), 60, 40, Color.green); House h3 = new House(new Posn(120, 300), 80, 60, Color.pink); House h4 = new House(new Posn(200, 300), 70, 50, Color.cyan); House h5 = new House(new Posn(270, 300), 90, 70, Color.yellow); House h6 = new House(new Posn(360, 300), 80, 60, Color.magenta); House h7 = new House(new Posn(440, 300), 90, 70, Color.orange); Tree t1 = new Tree(new Posn(550, 300), 40, 50, 80); Tree t2 = new Tree(new Posn(580, 300), 20, 30, 30); Cloud cloud; Sun sun = new Sun(20); TickyTack(Cloud cloud, Sun sun){ this.cloud = cloud; this.sun = sun; } public static void main(String[] argv){ ExamplesTickyTack ett = new ExamplesTickyTack(); TickyTack tworld = new TickyTack(ett.cloud, ett.sun); tworld.bigBang(600, 300, 0.1); } }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote