All times are UTC - 6 hours




Post new topic Reply to topic   Page 1 of 1
 [ 3 posts ] 
Author Message

 Post subject: Java coders look here!
PostPosted: October 7th, 2008, 7:52 pm 
Village Legend
Village Legend
User avatar

Joined: December 19th, 2003, 9:04 pm
Posts: 1,983
Location: The greatest place on earth - New England
Status: Offline
Alright so I know I haven't posted at RV since forever, but I need some help from the brilliant minds here that know how to code some Java.

Basically my dilemma is that I've been taking a Java Programming class since the start of the semester, and I have a couple of assignments due tomorrow. Only problem with this is that I haven't been paying attention and I have no idea how to do them. I'm not asking you guys to do the assignments for me, although if you did, that would own, and you can probably do it 10 times faster than I ever could.

If anyone can help me out let me know, here are the assignments.

Assignment 1:

Write an AreaTester program that constructs a Rectangle object and then computes and prints its area. Use the getWidth and getHeight methods. Also print the expected answer.

Assignment 2:

Write a PerimeterTester program that constructs a Rectangle object and then computers and prints its perimeter. Use the getWidth and getHeight methods. Also print the expected answer.

Thanks guys,

Prule :mrgreen:

__________________
Image
Hidden: 
I started the Miners' Revolution and joined up with the Fishers' Union before I had 100 posts.
I reported live from the first ever "Runevillage Event" in RSC.
I had a 'riddle topic' in General Chat where I would post riddles for people to guess and tally their points.
I was friends with the likes of PacoTaco, Berserk, and chatmasta.
I was voted in as a Runevillage Legend before leaving the place that I had put so much time into.

And now I'm back... again.


Top
 Profile WWW 
 

 Post subject: Re: Java coders look here!
PostPosted: October 7th, 2008, 11:28 pm 
Page
Page

Joined: December 29th, 2005, 4:40 pm
Posts: 81
Location: Norway
Gender: Male
Status: Offline
Here's how you should start:

import java.awt.Rectangle;

public class AreaTester {

  public static void main (String[] args) {
     int x = 0; // Rectangle X location
     int y = 0; // Rectangle Y location
     int width = 0; // Rectangle width
     int height = 0; // Rectangle height

     Rectangle rect = new Rectangle(x, y, width, height); // Constructs the Rectangle object
     // Your code goes here
   }
}


Hope that helps. :)

__________________
Image


Top
 Profile
 

 Post subject: Re: Java coders look here!
PostPosted: October 8th, 2008, 8:14 am 
Sorceror of Saradomin
Sorceror of Saradomin
User avatar

Joined: August 28th, 2003, 3:25 am
Posts: 3,825
Location: Wales, UK
Gender: Male
Status: Offline
If i was you - i would also do this

import java.util.Random;

Random difference = new Random( );
int diff = difference.nextInt(100) -50;

To make it make it produce a differnt sized rectangle on each run of the program - Probs will get extra marks

If you need any more help just post

__________________
Image
Image


Top
 Profile WWW 
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  Page 1 of 1
 [ 3 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Jump to:  

cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
The Village and this web site are © 2002-2012

ThePub 2.0 - Designed by Goten & Jackstick. Coded by Glodenox & Henner.
With many thanks to the Website Team!