Results 1 to 2 of 2
Thread: New to Java and very confused.
- 04-08-2011, 07:18 PM #1Member
- Join Date
- Apr 2011
- Rep Power
New to Java and very confused.
First let me state that this is a HW assignment and I absolutely do not want it done for me - I am making every effort to learn this on my own. I am just looking for input on where to start.
Here is the assignment:
Create a Java class to implement the Angle class, described below. The class should represent a mathematical angle with a value between 0 and 359 degrees. Required elements:
* an instance variable that represents the degree of the angle
* accessor (getter) methods that return the angle in degrees and in radians (2 separate methods)
* mutator (setter) methods that are analogous to the accessor methods; note that these must enforce the restriction about degree of angle stated above
- a default constructor that sets degrees to 0
- a single-argument constructor that takes an argument representing degrees and sets the angle degree accordingly; note that this must enforce the degree specification 0 <= angle < 360
* accessor methods that return the following information about the angle:
* accessor methods that return the values;
* a compareTo method that compares the calling object with another Angle object and returns a 1, 0 or -1 as a result of the comparison (results mean the same as they do in the String and Fraction versions)
* a main method that tests all of the other methods, using a loop so that the user can control the number of repetitions.
I understand what the Class is used for along with the getter and setter methods, but I don't understand how to put it all together. Are there any good examples that show something similar...or does anyone have any input on where they would start with this?
I'd go through the instructions one at a time, creating methods as defined by the instructions. If you're stumped by an instruction or your code has bugs, then come on back with your questions and your code.
Remember though to compile often and to not add any code if you have compilation errors until the errors have been fixed. A good link that can help you is the last one in my signature links below, "So, You Need to Write a Program..."
Good luck and welcome to the forum!
- By N00Bie in forum New To JavaReplies: 7Last Post: 02-18-2011, 01:33 AM
- By sweetjava in forum New To JavaReplies: 1Last Post: 08-09-2009, 03:03 AM
- By etherkye in forum JDBCReplies: 1Last Post: 07-02-2009, 07:35 PM
- By Dometic in forum New To JavaReplies: 10Last Post: 12-08-2008, 12:56 AM
- By Bibendum in forum New To JavaReplies: 3Last Post: 12-26-2007, 07:23 AM