• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

help converting my code into classes and arrays

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
so i know this code is still pretty rough but i need convert this code into classes and arrays. i unfortunately dont know how to do that so i was hoping for some advice.
here is my current code:

here is the file scanned in:



how do i scan in these strings in and store them in arrays and change "head" and "dependents" into classes?

(this code got posted at http://www.programmersheaven.com/mb/java_beginners/419488/419488/converting-my-current-code-to-classes-and-arrays/?S=B20000#419488 by accident and i cant figure out how to remove it. the website is buggy and auto submitted it before i could delete it)
 
Marshal
Posts: 75716
354
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You would need to create a HeadOfHousehold and a DependentInHousehold class; maybe both have a Person field. You could have a HeadOfHousehold field in the dependent class and a dependent[] (or, maybe better, a List<DependentInHousehold>) field in the HeadOfHousehold class.
Design your head and dependent classes before you try to put the whole thing together. What you have might be incompatible with those two classes, so you may find you have to lose a lot of what you have already written.
 
"I know this defies the law of gravity... but I never studied law." -B. Bunny Defiant tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic