CS46A Spring 19

8A

Complete the class XRectangle. An XRectangle has a x,y location of the upper left hand corner. It represents a rectangle of X's with 4 rows and 5 columns in random colors

You are given a class X which represents a graphical X and that can draw itself at a specified location in a specified color. You can look at its documentation to see the details. Open the X class and select "Documentation" in the upper right drop down menu.

Provide a constructor that takes the x, y coordinates of the upper left hand corner as parameters. Do not draw in the constructor

Provide the method

Other instructions

Your output for the final will look like this.

output for 8a

For the draft, complete the constructor. Implement the draw method to draw the first column all in red. You must use a loop.

8A draft:
8A final:

8B

Write an application CountryList. It will have a main method. In the main method, do the following:

Note: You must use an ArrayList and its methods. Do not fake it by just printing the correct strings. You will need to know how to use these methods in a situation where the output can not be faked.

 

For the draft,

8B draft:
8B final:

8C

Write a class Bookstore which manages Book objects.

The Book class is provided for you. It has a constructor that takes the title of book and its price as parameters. It has methods to getPrice and getTitle. Copy the Book class into your project. Do not change it in any way.

Bookstore has an instance variable ArrayList<Book>. Call the instance variable books. It has a no-argument constructor (That means it takes no parameters) which initializes the instance variable (the ArrayList of Book objects) to an empty ArrayList.

Provide these methods

Provide Javadoc.

For the draft, define the instance variable and implement the constructor. Also implement the add method.


8C draft:
8C final: