# CS 38 Arrays And Objects Shape Example Programs

Task #2 Arrays of Objects Section 3.8 Shape Classes discuss a step by step process for drawing a car. You will line draw the first 3 letters of your (first or last) name using an array to hold the x,y coordinates needed to draw the letters. The drawing should be similar to this:

The horizonal and vertical lines are 10 pixels wide. For diagonal lines you will have to estimate a width to make it consistent with the other widths, e.g. in my “K” I had to estimate the start/end points for the two diagonal lines. For letters with “curves” like B, C, D, J, G, O, etc. you will have to draw the curves with several straight line segments. For example an “O” should use enough diagonal lines to look good. Because the lines have a width you will have many (x,y) coordinates to keep track of. It’s highly recommended you “hand-draw” your letters on graph paper or you will lose track of your position.

LIke the Car class, write a separate class for each of the 3 letters. The constructor should take a starting (x,y) position to place your letter. For example my calls to the 3 constructors are:

CharI ii = new CharI(50,50); //draw it at position x=50, y=50
ii.draw(g2);

CharJ jj = new CharJ(130,50); //draw it at position x=130, y=50
jj.draw(g2);

CharK kk = new CharK(200,50); //draw it at position x=200, y=50
kk.draw(g2);

The separate class for each letter makes it easy to “move” your letters around and avoid having to “hand” edit (x,y) coordinates if you are a “little off”. I’m not requiring it but it would be impressive if your constructor included a scaling factor to enlarge or shrink the letter, for example CharS ss = new CharS(50. 100, 2.5) which tells a “S” constructor to draw the letter S at x=50, y=200 with 2.5 magnification.

## Why US?

##### 100% Confidentiality

Information about customers is confidential and never disclosed to third parties.

##### Timely Delivery

No missed deadlines – 97% of assignments are completed in time.

##### Original Writing

We complete all papers from scratch. You can get a plagiarism report.

##### Money Back

If you are convinced that our writer has not followed your requirements, feel free to ask for a refund.