• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Help converting my code to work with a driver class?

 
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi I had to make a program where a user inputs values and I have to test if they are a magic square. I was able to do that with the following code



but I have to make it so the user inputs the value through JOptionPane and so that the program uses a driver class. So here is my driver class



and here is my new main code



So how can I convert my code to use the values entered from the JOptionPane? Would I have to redo the entire code?
 
Sheriff
Posts: 13512
223
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
With over 50 posts to this site, you should have been told multiple times already that you need to format your code properly. This will help tremendously in getting more help from people. As it is right now, my only inclination to help is to tell you, once again, to do yourself and others a favor and format your code properly. Are you not using an IDE like Eclipse or NetBeans or IDEA? All it takes is a few keystrokes or if you're not up to doing that, a few clicks of the mouse.
 
Marshal
Posts: 64661
225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why do you have to change your code to work with a driver class? Most classes should have a public interface and any other code using the class uses that public interface. You need to program your driver class to work with the public interface.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!