1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2013
    Rep Power

    Simple constructor question

    Create two constructors - one which takes two double parameters (the initial values of x,y). The
    * second constructor will take another Geocache and initialize itself based on that geocache.
    * For both constructors set the Geocache's id to the current value of count (thus the first geocache will have the value zero)
    * when the Geocache is created, then increment the count value.

    Question 1: So I created first constructor, and second one requires me to take another constructor and initialize itself based on that geocache.. how do i do that?

    Question 2: How do I do the count part too?
    class Geocache {

    private int x, y;
    private double id;

    public Geocache(double a, double b){

    a= x;
    b= y;

    public Geocache(
  2. #2
  3. Lord of the Dance
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Oct 2003
    Rep Power
    As specified it will take a Geocache as argument instead of two double's.

    Then you will have to read the values from the passed object. (you do know how to get the value from your object?)

    One note about the id, it sounds like it is a counter shared across all instances of Geocache. To do this, you have to make it a static variable.

IMN logo majestic logo threadwatch logo seochat tools logo