Results 1 to 3 of 3
Thread: Absolutely Lost
- 12-03-2007, 02:42 PM #1
Member
- Join Date
- Dec 2007
- Posts
- 6
- Rep Power
- 0
- 12-03-2007, 05:37 PM #2Java Code:
public class Shapes { //I'm guessing these are ints since they are described as coordinates. int a,b; public Shapes(int a, int b){ this.a = a; this.b = b; } public int getA() { return a; } public int getB() { return b; } public void setA(int a) { this.a = a; } public void setB(int b) { this.b = b; } public void toPrinter(){ System.out.println("[" + a + "," + b + "]"); } } public class Orange extends Shapes { //Assuming these are ints. double radius; public Orange(int a, int b, double r){ super(a,b); this.radius = r; } public void toPrinter(){ System.out.println("[" + this.a + "," + this.b + "]" + "Radius: " + this.radius); } //this return type may need to be changed if coordinates or radius change public double getArea(){ return 3.14 * radius * radius; } public static void main(String[] args){ Orange blag = new Orange(3,4,1); blag.toPrinter(); System.out.println(blag.getArea()); } }
- 12-03-2007, 07:25 PM #3
Member
- Join Date
- Dec 2007
- Posts
- 6
- Rep Power
- 0
Similar Threads
-
need help with program im lost
By lifeturn in forum JCreatorReplies: 1Last Post: 10-28-2008, 08:09 PM -
Lost my javadocs
By orchid in forum EclipseReplies: 3Last Post: 04-30-2008, 10:45 PM -
A little lost with for loops and making a design
By LinxuS in forum New To JavaReplies: 5Last Post: 01-22-2008, 10:05 AM -
Help Needed - I'm so lost
By adlb1300 in forum New To JavaReplies: 3Last Post: 11-14-2007, 02:54 AM
Bookmarks