AVehicle - width = newwidth; Cabin.setWidth(width/2);...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
/* AVehicle.java * implements Vehicle to generate vehicle image according to constraints of assignment 6 * @author Molly Shult * Last Updated: 4/8/10 */ public class AVehicle implements Vehicle { int width; int height; Rectangle Cabin, Body; Oval FrontTire, BackTire; double scale; public AVehicle(int width, int height){ scale = 1; if (width<2.5*height){ width = (int)4*height; } width = (int)(width*scale); height = (int) (height*scale); Cabin = new ARectangle(width/4, 0, width/2, height); Body = new ARectangle(0,height,width,height); FrontTire = new AnOval(height/3,3*(height/2),height,height); BackTire = new AnOval(width-height- height/2,3*(height/2),height,height); } public void setHeight(int newheight){ height = newheight; Cabin.setHeight(height); Body.setHeight(height); FrontTire.setHeight(height); BackTire.setHeight(height); } public void setWidth(int newwidth){
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: width = newwidth; Cabin.setWidth(width/2); Body.setWidth(width); Point locCabin = new ACartesianPoint(width/4,0); Point locBody = new ACartesianPoint(0,height); Point locFrontTire = new ACartesianPoint(width/2-(7/6)*height,3*height/2); Point locBackTire = new ACartesianPoint(width/2+(1/6)*height,3*height/2); Cabin.setLocation(locCabin); Body.setLocation(locBody); FrontTire.setLocation(locFrontTire); BackTire.setLocation(locBackTire); } public Rectangle getCabin(){ return Cabin; } public Rectangle getBody(){ return Body; } public Oval getFrontTire(){ return FrontTire; } public Oval getBackTire(){ return BackTire; } public void setScaleFactor(double scaleNew){ scale = scaleNew; this.setHeight((int)(scale*width)); this.setWidth((int)(scale*height)); } public double getScaleFactor(){ return scale; } }...
View Full Document

This note was uploaded on 10/17/2011 for the course COMP 110 taught by Professor Stotts during the Fall '08 term at UNC.

Page1 / 2

AVehicle - width = newwidth; Cabin.setWidth(width/2);...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online