File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes David Smalley Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "David Smalley" Watch "David Smalley" New topic
Author

David Smalley

David Smalley
Greenhorn

Joined: Mar 24, 2003
Posts: 5
Need help new java student.
I am trying to get some help with an assignment for my first Java class. I have started a new job after 7 months and I am behind the power curve on these assignments. I would like any help or assistance. Here is the first assignment:
Create a program with:
1. One class
2. A main() method
3. At least two instance method (No static methods)
4. Local and instance variables (No static methods)
5. Final variable
6. Arrays
I can create a class, main method, but I do not understand how to write the whole program so it will all run I have no examples of how proper program code is written and what looks right! If anyone has any resources or places to look I will do it. Thank you for your time.
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
Hello David, welcome to JavaRanch! I recommend taking a look at this: Your first cup of Java...
[ March 24, 2003: Message edited by: Barry Gaunt ]

Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
David Smalley
Greenhorn

Joined: Mar 24, 2003
Posts: 5
Thanks Barry for your response. I am sorry for my newbiness. I am reading My first cup of java as of last night. I have read from Java text book and have a good understanding of arrays now. I still have a question I hope you can answer for me. How does one figure out a way to craft an idea into the assignment. I am under the gun and behind because of the new job. Any help would be appreciated. Thanks again for all your assistance. As I develope code I will post it. Thanks for all.
David Smalley
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
David, the first step has to come from you. Try and code anything, even if you just have classes A,B,C and variables x, y, z. The methods can do nothing at first. Just get some kind of outline that you can start filling in afterwards.
If you get that done, people have a handle to get hold of, and they can assist you.
John Lee
Ranch Hand

Joined: Aug 05, 2001
Posts: 2545
David,
You can walk in any bookstore or library, read a entry level java book there. I am sure you will learn how to write your first java program!
HTH,
David Smalley
Greenhorn

Joined: Mar 24, 2003
Posts: 5
Thanks to all of the responders. I have done two programs now and have some code I am trying to get it into shape. i keep getting complier errors. and I am having problems understanding what the next step is. I have read all of 'My first cup of Java' it has really helped but I still have to learn so much. I hope that this exceptable? Here is my code:

[ April 09, 2003: Message edited by: Thomas Paul ]
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
Sorry, but I'm not going through that lot. Let's take look at your assignment:

Create a program with:
1. One class
2. A main() method
3. At least two instance method (No static methods)
4. Local and instance variables (No static methods)
5. Final variable
6. Arrays

For 1 and 2:

For 3:

For 4:

For 5:

For 6:

For an exercise:

Not very imaginative but it minimally satisfies the assignment as you have stated it.
Part of learning Java is the correction of the compilation problems. It's not going to be easy.
[ April 03, 2003: Message edited by: Barry Gaunt ]
David Smalley
Greenhorn

Joined: Mar 24, 2003
Posts: 5
Here is my latest asignment.
At least three classes. Classes will be associated by Association not inheritance.
At least two instance methods.
At least two overload constructors.
A static variable and a static method (other then main).
The use of the "this" reference.
Private and public access modifiers only
Setters and Getters
An array of user-defined objects(other then strings)
And a partrige and a pear tree!!!
I have learned a lot but I still need help with the structure and an idea to wrap it all around.
Thanks so much to all for your help. I will be up late so if any ideas I will be awake.
Thanks again for all your help!
Thanks for all the Newbie!
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
Just tackle it one requirement at a time.
What have you got so far?


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
David Smalley
Greenhorn

Joined: Mar 24, 2003
Posts: 5
The huge code previous is what I have been using I have it all working except were Icon icon2 area is it will not compile. Thats is at the bottom on the code. everything else compiles. If you could take alook at that section it would be greatly appreciated, thanks for all your help! David Smalley
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
I think you are overdoing it. Why make a simple excercise so complex? Keep your classes small and simple.
Take each requirement one at a time:
1) At least three classes. Classes will be associated by Association not inheritance.
2) At least two instance methods.
3) At least two overload constructors.
4) A static variable and a static method (other then main).
5) The use of the "this" reference.
6) Private and public access modifiers only
Setters and Getters
7) An array of user-defined objects(other then strings)

Try this:
Create three classes, Course, Instructor, and CourseBuilder. CourseBuilder is the only one with a main method. The Course class will have name of the course, description, and an Instructor. The Instructor class will have a name, mail drop, annual salary. All variables in both classes will be private with public get and set methods. For example:

The CourseBuilder will create 3 Course objects and two Instructor objects. One of the Instructor objects will be assigned to two Course objects. The Course objects will be stored in an array. I am sure you can figure out how to fulfill the reamining objectives.
By the way, I like your teacher's assignments.


Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
 
 
subject: David Smalley
 
Similar Threads
Java Static Problems
why is main method always static??
Basic Java
why can't a function be called from a static context
JButton