• Post Reply Bookmark Topic Watch Topic
  • New Topic

Defining object classes  RSS feed

 
Allen Watts
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everyone,

I have hit a rut and I cant figure out where my problems are.

I need to create a class called course and then create an object for each course.

I need to have an output that looks like this:

Course objects have a code (e.g. IT1006) and credit hours (e.g. 6)
The number inside the [] is the display order number
The number inside of the () is the credit hours for the course

[1] IT1006 (6)
[2] IT4782 (3)
[3] IT4789 (3)
[4] IT4079 (6)
[5] IT2230 (3)
[6] IT3345 (3)
[7] IT2249 (6)


Here is what I have written this far...



Any help would be greatly appreciated!

-Allen
 
Carey Brown
Saloon Keeper
Posts: 3328
46
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Class names should begin with an upper case letter. Variables and methods should begin with lower case letters.

Requirements about "order" are a little vague. I suspect that you should end up with an array of Course objects and that your prints should be in a loop where the loop counter is printed first.

You should create a constructor that takes the parameters instead of setting them after creating the object.

Your println() String concatenation (+) is wrong...try
 
Allen Watts
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Awesome!  your suggestions were exactly what I needed!  It is working with the expected output!  Thank you so much!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!