Use the following files: JFrame.java TileFloorComponent.java TileFloorViewer.jav
ID: 3888358 • Letter: U
Question
Use the following files:
JFrame.java
TileFloorComponent.java
TileFloorViewer.java
green, ue, buck, and cv Clete e class T1leFloor. Use the costants detined to vin tbe starte coe. Yu ustuse nesed Loups. Daw the ows and teci the coluanns tostch Codecheck cutpot For the colors, use the Color coestants in the Color class. Color.RED erc) Te TileFloor wilue to msttuctons . publ1 Tile Flor int 21 int y te re x and v are t e coord na esaftie upper left hand corner of the floor Create a Randc n object as ng the ccestu tor that takes seed. Use 234567 as the seed Use S as the ce a namber of rcws and as the de ant the minber of coimns Do not draw in the enactor coustructor that takes a seed.Ue 1231567 as the seed Do not draw in the constructor. The TileFloor wiil hare these methcds public void draw (Graphics2D g2) d th fleor wirh the flledqsat thex yordinates s a nad loop private Color randomColor ) andomly rerns a Coler object either red green, ble black ar cyan. Use the Random ohject yoa creared in the constructor to determine which o rerurn Vou need ts if else if else sttestrucrure . publio void setX(int x) sets a newx cocrdinate. Implemected for you) . publie void setr (int y) setsaneyce Implneted you) GREEN 1), eut Color GREEN Uee thedefined otmt, not the numb , 1 ctc Provide Javadoc Because due Random obect s nated wthaseed, you 11ll all get he sazne dtawmg everv tme hat is so Codecheck can check Your output willloo like thisExplanation / Answer
import java.awt.Graphics; import java.awt.Graphics2D; import javax.swing.JComponent; public class TileFloorComponent extends JComponent { private static final long serialVersionUID = 1L; public void paintComponent(Graphics g) { // Recover Graphics2D Graphics2D g2 = (Graphics2D) g; TileFloor floor = new TileFloor(15, 20); floor.draw(g2); floor.setX(100); floor.setY(50); floor.draw(g2); floor = new TileFloor(50, 200, 10, 12); floor.draw(g2); } } import javax.swing.*; public class TileFloorViewer { public static void main(String[] args) { JFrame frame = new JFrame(); frame.setSize(300, 400); frame.setTitle("TileFloor"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); TileFloorComponent component = new TileFloorComponent(); frame.add(component); frame.setVisible(true); } } void showframe(int posx, int posy) { int hr=196, vr=179; // These are ascii character which display the lines int crossbr=197; // Another ascii character int x=posx, y=posy; int i,j; gotoxy(35,4); cprintf("TIC TAC TOE"); gotoxy(35,5); for(i=0;iRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.