aspose file tools*
The moose likes Beginning Java and the fly likes java problem help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "java problem help" Watch "java problem help" New topic
Author

java problem help

Troy Johnson
Greenhorn

Joined: Sep 24, 2003
Posts: 20
Hello. I am trying the following modifications to the problem.
1) Make all data members private.
2) Create appropriate get and set methods.
3) Write a test program that creates an array of 10 Planets.
4) Use "for" loops to fill the array, set the number of moons and rings for each planet.
However, I seem to be having a few problems getting everything figured out. Could anyone offer any suggestions or ideas to assist me. I seem to be a little confused. Thanks.
Here is the original code;

Here are the modifications that I have made:
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
I think you have some significant errors.
Why did you change the name of the class? This is often a no-no for instructors.
If class Planet originally had instance variables moons and rings, why did you move them to class Planets? The instructions say only to make them private, not to move them.
Often get and set method names start get and set and then are followed by the name of the instance property they are encapsulating, capitalizing the starting character. So, the names setMoons and getMoons would be more common than setmoons and getmoons.
As far as creating the array is concerned, this planets p[] = new Planets1[10]; definitely won't compile with the posted class definitions.
Also, the brackets surrounding the main method of Planet1 are no good. This example also will not compile.
You might want to try to start over, tackling each requirement one at a time, asking questions here to help resolve compiler errors and understanding the concepts of the instructions.
Good luck.


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Yan Lee
Ranch Hand

Joined: Sep 15, 2003
Posts: 94
public class Test
{
// code removed by Marilyn
}

I think we should wait to see his reworked code, p, ratherthan write his assignment for him. -- MdQ
[ October 28, 2003: Message edited by: Marilyn de Queiroz ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java problem help