This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Making 2 classes with object.method  RSS feed

 
Richard Hernandez
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've been having a bit of trouble with this one.
All I need to do is make another class and have object.method
(it uses 10 input #'s into an array,displays it,sorts them forwards and backwards)
[ edited to remove the evil tab character and to preserve formatting using the [code] and [/code] UBB tags -ds ]
[ March 31, 2004: Message edited by: Dirk Schreckmann ]
 
KR Campbell
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not quite sure I understand what you want to do.
Perhaps what you mean is that you want some way to call the actions contained in your class from another class? In which case it would be better if you defined your code in methods other than main.
Assume first that we leave the code as it is, in one big chunk. Put it in another method, perhaps called sortIt() within you class definition. You can then call

A better approach might be to break your program down into tasks, such as getUserInput, performBubbleSort and outputResults. You could then call those methods from within sortIt as before. Your method for getting user input seems a bit clumsy with ten JOptionPanes in a loop. Maybe have a go at using System.in.read() ?
Sorry if I've misunderstood your question.
Kenny
 
Richard Hernandez
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I finished it.
thnks you
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!