CS520 Week 4 Assignment solution

$24.99

Original Work ?
Category: You will Instantly receive a download link for .ZIP solution file upon Payment

Description

5/5 - (2 votes)

CS520 Week 4 Assignment (Lego Mania)General Rules for Homework Assignments•You are strongly encouraged to add comments throughout the program. Doingso will help your facilitator to understand your programming logic and grade youmore accurately.•You must work on your assignments individually. You arenot allowedto copy theanswers from the others.However, you are encouraged to discuss approachesto the homework assignment with your section mates and the facilitator in yoursection via the discussion board.•Each assignment has a strict deadline. However, you are still allowed to submityour assignment within 2 days after the deadline with a penalty. 15% of the creditwill be deducted unless you made previous arrangements with your facilitatorand professor. Assignments submitted 2 days after the deadline will not begraded.•When the termlastNameis referenced in an assignment, please replace it withyour last name.You are strongly encouraged to add comments into your program!Create a new Java Project in Eclipse named HW4_lastName.Createa package namedcs520.hw4and complete the following by writing the appropriate classes under thispackage

Part 1 (50 points)Create a Swing GUI application that displays the following graphics of red and bluelego blocks. The tower is always built from bottom row to top row, left to right in eachrow.Write a class namedLegos1extending theJFrameclass with the followingspecifications.a. Declare the integer type instance variablesstartX, startY, legoWidth,and legoHeight. The first two values represent the top-left coordinatesof thefirst red block in the bottom row. The next two values are thewidth and height of each block.b. Declate another integer instance variable,baseLength. This representsthe number of blocks in the bottom row.c. In the constructor, specify the appropriate window title using yourlastNameand assign the above instance variables with the values 20,300, 50, 20, and 10, respectively.d. In thepaintmethod, using nested loops, fill the pattern from the bottomrow all the way to the top. Notice, that the number of blocks decreasesby one for each row. Use thebaseLengthvariable to control the loops.e. In themainmethod, create the application object, set its size to 550 by325 and its visibility to true to test the above graphics