aspose file tools*
The moose likes Beginning Java and the fly likes Wheel Project Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Wheel Project" Watch "Wheel Project" New topic
Author

Wheel Project

Jerrard Maniece
Greenhorn

Joined: Jul 16, 2007
Posts: 10
I was wondering if anyone could help me out on my wheel project. I am kind of new at Java and needed some help. This project is a wheel and has to have 5 spokes. So far I have.....

class Spoke { }

class Wheel
{
Spoke[] spokes = new Spoke[5];
}

any help is accepted. Thanks again.
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11497
    
  16

well, you have a start. you have a spoke class, and a wheel class. you have an array to hold your spokes. However, you have not yet created any spokes.

declaring an array is like saying "i want a carton that can hold 5 eggs", and you get a carton. There are, however, no eggs in it.

do you know how to create the spokes and put it into the array?


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Jerrard Maniece
Greenhorn

Joined: Jul 16, 2007
Posts: 10
Naw. Can you help me out with that?
Manuel Leiria
Ranch Hand

Joined: Jul 13, 2007
Posts: 171
Originally posted by Jerrard Maniece:
I was wondering if anyone could help me out on my wheel project. I am kind of new at Java and needed some help. This project is a wheel and has to have 5 spokes. So far I have.....

class Spoke { }

class Wheel
{
Spoke[] spokes = new Spoke[5];
}

any help is accepted. Thanks again.



Manuel Leiria<br /> <br />--------------<br />Peace cannot be kept by force; it can only be achieved by understanding. <br /> Albert Einstein
Jerrard Maniece
Greenhorn

Joined: Jul 16, 2007
Posts: 10
^^Thanks. I added what you pasted, but it's saying "Return Type Method Is Missing". It's saying that at Wheel(). I know wheel is a method, but not sure why that error is coming up.
Jerrard Maniece
Greenhorn

Joined: Jul 16, 2007
Posts: 10
never mind, I figured it out. It's public void Wheel! Thanks
Jerrard Maniece
Greenhorn

Joined: Jul 16, 2007
Posts: 10
Ok. I want to put this in a Applet to show up. At the top I put:

import java.applet.*;

public class Wheel extends Applet

but nothing didn't show up......
Manuel Leiria
Ranch Hand

Joined: Jul 13, 2007
Posts: 171
Originally posted by Jerrard Maniece:
^^Thanks. I added what you pasted, but it's saying "Return Type Method Is Missing". It's saying that at Wheel(). I know wheel is a method, but not sure why that error is coming up.


Wheel is not void, it's the constructor for the class Wheel (the method has the same name as the class).

Anyway I have no idea what you're trying to do and I think neither do you. What exactly are you trying? an applet with a draw of a wheel?
Jerrard Maniece
Greenhorn

Joined: Jul 16, 2007
Posts: 10
^^^, Ya, I just want the drawing of the wheel to show up in the applet.
Manuel Leiria
Ranch Hand

Joined: Jul 13, 2007
Posts: 171
Originally posted by Jerrard Maniece:
^^^, Ya, I just want the drawing of the wheel to show up in the applet.


Int that case you should look at this tutorial:

http://java.sun.com/docs/books/tutorial/deployment/applet/getStarted.html
Jerrard Maniece
Greenhorn

Joined: Jul 16, 2007
Posts: 10
Ok, I will check out that and get back with yall, thanks again for the help.
Manuel Leiria
Ranch Hand

Joined: Jul 13, 2007
Posts: 171
Glad to help!
Jerrard Maniece
Greenhorn

Joined: Jul 16, 2007
Posts: 10
I got another question. I was wondering do they have a method for a Circle. I see one for Polygon, Arc, Line, Rec, Oval, Round Rect....anything for a Circle?
Manuel Leiria
Ranch Hand

Joined: Jul 13, 2007
Posts: 171
Originally posted by Jerrard Maniece:
I got another question. I was wondering do they have a method for a Circle. I see one for Polygon, Arc, Line, Rec, Oval, Round Rect....anything for a Circle?


A circle is a special kind of oval

Jerrard Maniece
Greenhorn

Joined: Jul 16, 2007
Posts: 10
Ok! Do I just play with the numbers to get it to look like a circle???
Manuel Leiria
Ranch Hand

Joined: Jul 13, 2007
Posts: 171
Originally posted by Jerrard Maniece:
Ok! Do I just play with the numbers to get it to look like a circle???


Sure! An oval has two different radios and a circle as only one radio, so put the same value for the two parameters that defines the radios and you'll get a circle
Jerrard Maniece
Greenhorn

Joined: Jul 16, 2007
Posts: 10
So far I got:

import java.applet.Applet;
import java.awt.Graphics;

import javax.swing.JFrame;

public class DrawOval extends Applet
{
public void paint (Graphics g)
{
g.drawOval(10, 50, 200,
getSize() .height - 384);
getSize() .getWidth();

Somewhat correct???
 
 
subject: Wheel Project