Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

***In Java*** -Write a class called Framebuffer with two fields, one called buffer, that stores a 2 dimensional array of characters and a field called

***In Java***

-Write a class called Framebuffer with two fields, one called buffer, that stores a 2 dimensional array of characters and a field called frameNumber that stores the number of the frame, and it will increase every time we 'paint one.

-Create a constructor with two parameters: height(for the number of rows) and width(for the number of columns) of the screen. A new FrameBuffer should be working on frame number 0, and should start lled entirely with spaces. If either the height or width is less than 10, use 10 instead of the value of the parameter. Add two getter methods for the height and width that return the values that had been passed through the constructor(don't create new fields).. Next add a method called "paint" that doesn't have parameters or a return value. It should write the contents of the bu er to the terminal, surrounding the entire thing with a rectangle of asterisks (`*'). Have it print a line containing the number of columns, a lowercase 'x', the number of rows, a space, the word "Frame", another space, and the frame number: like this 60x20 Frame 7. It should also update the frame number and overwrite the buffer with spaces.

-Next create some draw methods... create one called drawSingleChar that has three parameters, a y-value(row number), x-value (column number), and character. This method doesn't return a value. If the row and column number are both valid(the row must be at least 0 and less than the height) copy the character to the speci ed location in the bu er. Otherwise, do nothing.

Next create a method called drawRectangleFill with five parameters: the y-value of the top-left corner, the x-value of the top-left corner, the height, the width, and a character. If the first four parameters all have reasonable values, modify the buffer drawing a rectangle with the top left corner at the specifed y-value and x-value filling in the rectangle of the specified width and height.

The next method should be called drawRectangleEmpty and it should have the same parameters of the previous method(drawRectangleFill) and it should work in the same way, except that it leaves the interior of the rectangle empty.

The next method should be called drawRectangleCheck and it should have the same parameters of the previous two methods and work in a similar way. except that only every second character of the rectangle is written to, like a checkerboard.

Next add a method called drawCirlceEmpty with four parameters: the y-value of the center, the x-value of the center, the radius, and a character. Make sure that the first three parameters have reasonable values(the entire circle will t in the frame), the method should draw the outline of the specified circle to the buffer. (Some Hints: You will need to use the pythagorean theorem and you will also need to use methods from the Math class as well as the Math.round method)

For the last method, create one named drawCircleFull that is set up and works just like drawCircleEmpty, except that it includes the interior of the circle(any location with a distance less than the radius)

Now write a Main class with a main method. Create a FrameBuffer with 24 rows and 80 columns, then do the following with it, in order:

- Draw a filled rectangle from row 4, column 44 with height 20 and width 1 from pipe characters. (a flagpole)

- Draw an empty rectangle from row 4, column 45 with height 8 and width 20 from plus characters(border of a flag)

- Draw a checked rectangle from row 5, column 46 with height 6 and width 18 from asterisk characters(interior of a flag)

- Draw an empty rectangle from row 19, column 30 with height 5 and width 3 from exclamation point characters. (a left leg)

- Draw an empty rectangle from row 19, column 20 with height 5 and width 3 from exclamation point characters. (a right leg)

- Draw an empty rectangle from row 13, column 18 with height 6 and width 17 from exclamation point characters(a torso)

- Draw an empty rectangle from row 14, column 34 with height 3 and width 10 from exclamation point characters(a left arm)

- Draw an empty rectangle from row 14, column 9 with height 3 and width 10 from exclamation point characters. (a right arm)

- Draw an empty circle from row 9, column 26 with radius 4 from exclamation point characters(a helmet)

- Draw a single uppercase 'U' at row 15, column 24. Draw a single uppercase 'S' at row 15, column 26. Draw a single uppercase 'A' at row 15, column 28.

- Draw a lled circle from row 18, column 65 with radius 3 from percent sign characters.(the earth)

- Paint the frame, which should be the same picture of an astronaut planting a flag on the moon

Here is an example of the finished product:

image text in transcribed

1+ USA 2777 24x80 Frame 0

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database Management Systems

Authors: Mark L. Gillenson

2nd Edition

0470624701, 978-0470624708

More Books

Students also viewed these Databases questions