Having trouble with drawing a Car with TurtleGraphics

hey guys
i need help on a program that should draw a car, erase it, and draw it again but in a different spot on the window. Now I have all of this except when the car is drawn again the wheels aren't moved with the car.
Heres the main:
import TurtleGraphics.StandardPen;
import java.awt.Color;
import TerminalIO.KeyboardReader;
public class TestCar
public static void main(String[] args)
  KeyboardReader reader = new KeyboardReader();
  Car firstCar = new Car();
  firstCar.drawCar();
  reader.pause();
  firstCar.eraseCar();
  reader.pause();
  Car secondCar = new Car(100, 100);
    secondCar.drawCar();
} Here is the class:
  import TurtleGraphics.StandardPen;
import java.awt.Color;
public class Car {
private StandardPen pen;
private double xPosition, yPosition;
public Car ()
   xPosition = 0;
   yPosition = 0;
   pen = new StandardPen();
   pen.setColor(Color.red);
public Car(double x, double y)
   this();
   xPosition = x;
   yPosition = y;
public void drawCar()
    drawRectangle (-150,75, 300, 150);
    drawRectangle (-50, 125, 100, 50);
    drawCircle (124, -230, 40);
    drawCircle (-124, -230, 40);
  public void drawRectangle (double x, double y, double length, double width)
    pen.up();
    pen.move(x + xPosition, y + yPosition);
    pen.down();
    pen.setDirection(270);
    pen.move(width);
    pen.turn(90);
    pen.move(length);
    pen.turn(90);
    pen.move(width);
    pen.turn(90);
    pen.move(length);
  public void drawCircle(double x, double y, double radius)
   double side = 2.0 * Math.PI * radius / 120.0;
   pen.up();
   pen.move((xPosition + x + radius), ((yPosition + y) - side)/ 2.0);
   pen.setDirection(90);
   pen.down();
    for(int i = 0; i< 120; i++) 
     pen.move(side);
     pen.turn(3);
public void eraseCar()
    pen.setColor(Color.white);
    drawCar();
    pen.setColor(Color.red);
} Also the car is supposed to move across the screen once drawn the second time but i haven't figured that out yet. Maybe with a thread:
public void oneSec()
   try
   Thread.currentThread().sleep(1000);
   catch (InterruptedException e)
     e.printStackTrace();
   }  If anyone can help it'd help alot thanks

i fixed the part about the wheels now but im stuck on how to make the car move on the turtleGraphics window once it is drawn the second time.
Would this thread help it at all?
public void oneSec()
   try
   Thread.currentThread().sleep(1000);
   catch (InterruptedException e)
     e.printStackTrace();
  }

Similar Messages

  • Having trouble connecting computer to TV with sound

    I have a 2010 macbook pro and a samsung LN40B550 LCD HDTV - having trouble connecting computer to TV with sound - I'm not sure which connectors I need and have purchased a few that aren't working (HDMI: DVI cable & Mini - DP to DVI adaptor).  Any help would be greatly appreciated. Thanks

    Sorry to tell you that DVI does not support sound.  You either have to use a HDMI cable (with the appropriate adapter) or tap your audio output port with a 'Y' type cable configuration for sound.
    Ciao.

  • I am having trouble connecting my iPad mini with my lap top that run Xperia

    I am having trouble connecting my iPad mini with my lap top that run Xp

    Hi..I've had a variant of this problem; my internet was accessible but my devices on wifi could not see the PC on Lan. That meant no iTunes syncing, Airplay from iTunes etc.
    Dlink has a strange default setting that isolates Wifi & Wired connections into different subnets.I'm assuming you have DHCP setup on your router and you're PC or MAC has internet access via the same router. Try the following steps to see if this solves the problem for you-
    1. Go to Setup -> Local Network  and Uncheck the box that says 'Configure the second IP Address and Subnet Mask for LAN' - Hit Apply
    2. Go to Wireless -> Wireless Basic and Uncheck 'Enable MultiAP Isolation' - Hit Apply
    3. Restart your Router
    Let me know if this solves your problem. I've been frustrated by my problem for months & had nearly given up.
    J

  • I have an iphone 4 just updated my iTunes and now i'm having troubles to sync my iPhone with iTunes... can anyone help me plz?

    i have an iphone 4 just updated my iTunes and now i'm having troubles to sync my iPhone with iTunes... can anyone help me plz?

    You need to do as provided. If no change after restoring as a new iPhone or not from the backup, the iPhone has a hardware problem.

  • Having trouble maintaining remote desktop connection with Mavericks.  What is this about needing RDC 3.7.1 with Mavericks.  I downloaded RDC 3.7.1 but it does not replace RDC 2.1.0 previously installed.

    Having trouble maintaining remote desktop connection with Mavericks.  What is this about needing RDC 3.7.1 with Mavericks.  I downloaded RDC 3.7.1 but it does not replace RDC 2.1.0 previously installed

    Lucky you, it did not work for many users (which as it should be) so MS produced a new version, for ML and Mavericks.
    It's in the App Store, for free.
    FYI, I assume that you were attempting to post a picture, no one can see it (except maybe you) because it is on your computer rather than the forum server.
    file:///Users/dbrant/Desktop/About%20Apple%20Remote%20Desktop%203.7.1.webloc
    Use the small camera icon in the editor toolbar to post it.
    It also looks like you attempted to use Apple Remote Desktop, which does not do Windows.

  • I seem to be having trouble "save" or "save as" with jpg files. Any Suggestions?

    I seem to be having trouble "save" or "save as" with jpg files. Any Suggestions?

    By the way, a full uninstallation and reinstallation is a bit heavy-handed and is not always necessary.
    Keep in mind that with Photoshop CS6 the Plug-ins subfolder is now normally completely empty.  So to undo an inappropriate copy of plug-ins generally you can just delete all the copied plug-ins and that will restore proper Photoshop CS6 operation.
    Then you can reinstall your needed 3rd party plug-ins one by one.
    -Noel

  • I seem to be having trouble "save" or "save as" with jpg files.

    I seem to be having trouble "save" or "save as" with jpg files. Any suggestios?

    Awol2010 wrote:
    Any suggestions?
    Yes. - clarify what trouble(s) you are having.

  • Hi, i'm having trouble in filling a jtable with data

    hi, i'm having trouble in filling a jtable with data, but the real problem is that i have stablished a JDBC connection throught the windowsxp ODBC to my database written on microsoft access platform, so i created my table
    public CenterPanel(){
    panel = new JPanel();
    dataTable = new JTable(10,10);
    dataTable.setBorder(BorderFactory.createLineBorder(Color.black,2));
    panel.add(dataTable);
    setLayout(new BorderLayout());
    add(panel,BorderLayout.CENTER);
    i can see the table on my driver, but i want to fill it by connecting to the database and fil the fields from the database, i have the code to connect and retrieve the fields but on the dos, i want to fill them in the table,
    the code for accessing is
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
         Connection conn1 = DriverManager.getConnection      ("jdbc:odbc:EHLAN",
                             "marius","svasdiga");
                   Statement stmt1 = conn1.createStatement();
                   Statement stmt2 = conn1.createStatement();
                   ResultSet rs1 = stmt1.executeQuery ("select * from Appartment");
                   System.out.println("App. Num, Stair Num, Elec. Num");
              while (rs1.next()) {
                   System.out.print (rs1.getInt ("appnum") + ","+" ");
                   System.out.print (rs1.getString ("staircase") + ","+" ");
                   System.out.println (rs1.getInt("electrnum") );
    ResultSet rs2 = stmt2.executeQuery ("select * from Person");
    System.out.println("First Name, Last Name, Blood Type");
              while (rs2.next()) {
                   System.out.print (rs2.getString ("namef") + ","+" ");
                   System.out.print (rs2.getString ("namel") + ","+" ");
                   System.out.println (rs2.getString("bloodType") );
    so help me to fill this data to the table. thank you
    yours sincerely,
    marius ajemian

    hi, i'm having trouble in filling a jtable with data, but the real problem is that i have stablished a JDBC connection throught the windowsxp ODBC to my database written on microsoft access platform, so i created my table
    public CenterPanel(){
    panel = new JPanel();
    dataTable = new JTable(10,10);
    dataTable.setBorder(BorderFactory.createLineBorder(Color.black,2));
    panel.add(dataTable);
    setLayout(new BorderLayout());
    add(panel,BorderLayout.CENTER);
    i can see the table on my driver, but i want to fill it by connecting to the database and fil the fields from the database, i have the code to connect and retrieve the fields but on the dos, i want to fill them in the table,
    the code for accessing is
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
         Connection conn1 = DriverManager.getConnection      ("jdbc:odbc:EHLAN",
                             "marius","svasdiga");
                   Statement stmt1 = conn1.createStatement();
                   Statement stmt2 = conn1.createStatement();
                   ResultSet rs1 = stmt1.executeQuery ("select * from Appartment");
                   System.out.println("App. Num, Stair Num, Elec. Num");
              while (rs1.next()) {
                   System.out.print (rs1.getInt ("appnum") + ","+" ");
                   System.out.print (rs1.getString ("staircase") + ","+" ");
                   System.out.println (rs1.getInt("electrnum") );
    ResultSet rs2 = stmt2.executeQuery ("select * from Person");
    System.out.println("First Name, Last Name, Blood Type");
              while (rs2.next()) {
                   System.out.print (rs2.getString ("namef") + ","+" ");
                   System.out.print (rs2.getString ("namel") + ","+" ");
                   System.out.println (rs2.getString("bloodType") );
    so help me to fill this data to the table. thank you
    yours sincerely,
    marius ajemian

  • I'm having trouble synching my Outlook Calendar with my iPhone.   We use Outlook in my office so it's the only Calendar I use, so I can share inter-office  Used to use Mobile Me and I terminated that. Prior to this Outlook synched fine.  Prior to having m

    I'm having trouble synching my Outlook Calendar with my iPhone iniTunes
    We use Outlook in my office so it’s the only Calendar I use, so I can share inter-office
    Used to use Mobile Me and I terminated that. Prior to this Outlook synched fine.
    Prior to having my iPhone I only had one type of Calendar in Outlook
    I know have 'Calendar 5' on my Outlook, but that doesn't show up on my iPhone.
    iPhone does give me several other numbered Calendars – but no ‘Calendar 5’
    I need to figure a way to get all this synched correctly
    very frustrating!

    Take a look of this link, http://support.apple.com/kb/HT1701

  • Why am I having trouble signing in to iTunes with my AppleID? I change it

    Why am I having trouble signing in to iTunes with my AppleID? Once I go through the motions to reset my password on Apple's website & go back to iTunes, I still can't sign on. Should I have two passwords? Is there something I'm missing??

    Yep. Good point.
    To completely shut it down, even in the background, double click the home button to display the row of apps. Then press and hold the Facetime app until the app displays a minus sign. then touch the minus sign.
    The app is now stopped !

  • I am having trouble using my I phone with Icloud. I tried diabling it & all my contacts have been cancelled.

    I am having trouble using my I phone with Icloud. I tried diabling it & all my contacts have been cancelled.

    OK, I called Plantronics and it was an easy fix.  You need to hold down the volume up button and the power button on (on the headset) at the same time until the lights on the headset start flashing red and blue.  Then turn on the phone Bluetooth and it pairs up just fine.
    Thanks fo rthe help!!

  • I'm having trouble connecting my Intel iMac with the internet using wifi router

    I'm having trouble configuring my iMac to accept a connection with my Telstra Elite mobile broadband Wifi router.
    The iMac's Wifi is turned on and the elite router is selected in the Wifi list with a tick.
    The router is turned on, and connected to the internet.
    I'm able to surf the net and collect emails using my MacBook Pro ( what I'm using now) and my iPad with no hassles by connecting them to the Telstra Elite Wifi router. But I'm unable as yet to get a connection using the iMac.
    The Telstra router accepts up to 5 simultaneous connections.
    At present the display on the router says that three devices are connected. They being the iPad, the MacBook Pro and the iMac.
    Can anyone help me out?
    Gregory

    hburgess3 wrote:
    I'm having trouble connecting my apple tv to the wifi on my campus. To connect to this wifi on a computer or iphone you have to install a program.
    Why?
    Contact the school IT department,

  • I just had my logic board replaced. now im having trouble using the interent even with a strong connection and the internet is working on other devices!! please help me :(

    I just had my logic board replaced. i am now having trouble with using the interent even with a strong connection. all other devices are having no problem with the internet. please help

    Test while started in Recovery : if the problem persists, then it likely is a hardware issue.
    Resetting the System Management Controller (SMC) probably won't change anything, but you can readily do it before contacting the repairers.

  • I am having trouble getting a powerpoint made with keynote to advance with the arrow keys

    I am having trouble getting a powerpoint made in keynote to advance using the arrow keys when I save it to a flashdrive.

    Hi Wayne,
    Thank you for this response.  I have tried this but when I start enterring $ amounts some, such as $6.00, go in OK others such as $4.00 appear as a date ie 4 Oct 12.  
    Kind regards
    Paul

  • Ipod classic having trouble to connect my car USB

    I use to connect everyday in my new camry 2012 but recently it is not connecting through USB . when i plugin into USB it just shows charging . when i connected to my laptop its works fine.
    i checked with my wife iPhone , it is working fine in my car with USB.

    Reset the iPod and connect it back to the Car Audio.
    After charging till full charge, at least 2 hours (preferably 4 hours)
    Toggle the Hold switch, make sure you dont see the red mark when you do the  next step
    Reset the iPod -> Press Menu and Center button simultaneously for about 10 secs or till the Apple Logo comes ON
    Then release the buttons
    Select your preferred language.
    Connect to the Audio System.
    Here is the Apple support Article on the 5Rs
    http://www.apple.com/support/ipod/five_rs/classic/
    Good luck!

Maybe you are looking for