• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

call second constructor?

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My program currently does not increment for each new student object created although this was defined in a larger constructor in the Student class (that calls upon a smaller constructor that generates a student id that should increment for each new student).

I'm uncertain of how to go about accomplishing this.
Should I be creating a whole set of Student objects again, now using the second constructor, because the contstructor I called for the Student object array didn't take the student id as an input parameter?

I barely understand what I'm doing and I've been at this all day...any hints or guidance is appreciated.


 
N. Gonzalez
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I also tried this and it didn't work...



Need some direction, please...
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

These two lines are giving you the problem. For each object, you set the id to 1000 and then increment it by one. But since this happens for each student, you never get anywhere with the incrementing.

You really want this to be two variables. One to keep track of the current maximum assigned student id and one to keep track of the student id for that particular student. Tip: Think about which one of these needs to be static.
 
N. Gonzalez
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So are you saying one will be a static class variable and one and instance variable?

I guess I'm confused with the instructions that the constructor should generate the student id.
 
Who knew that furniture could be so violent? Put this tiny ad out there to see what happens:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic