title: How do I create an object from another class (BlueJ)
body: <p>I am making a program that simulates a Store and a Member. I am trying to write a method, memberRegister2(). This method is the the Store class but calls the constructor from the Member class to make a member object. This method is to be passed the name, id and pinNumber as parameters and then creates the Member object, which is to be stored in a local variable 'member'. I have no idea how to do this. As you will see from the code below I have tried to use the 'Member member = new Member()' But i do not know how to make the parameters user input.
  (P.S I am using BlueJ)
  Here is my code for both classes hopefully making my question make more sense. I am very new to java so excuse bad coding.</p>
  
  <pre><code>public class Store
  {
      // instance variables
      private String storeName;
      private int total;
  
  //Member member;
  
  /**
   * Constructor for objects of class Store
   */
  public Store(String newStoreName, int newTotal)
  {
      // initialise instance variables
      storeName = newStoreName;
      total = newTotal;
  
  }
  
  //Accessor Methods
  public String getStoreName()
  {
      return storeName;
  }
  
  public int getTotal()
  {
      return total;
  }
  
  public void memberRegister1(Member newMember)
  {
      System.out.println("Salford Thrifty " + storeName + ": Welcome " + newMember.getName() + " (id:" + newMember.getId() + ")" );
  
  }
  
  public void memberRegister2()
  {
      //Member member = new member(memberName, memberId, memberPinNumber);
  
  
  }
  //Mutator Methods
  public void newStoreName(String newName)
  {
      storeName = newName;
  }
  
  public void newTotal(int newTotal)
  {
      total = newTotal;
  }
  }
  </code></pre>
  
  <p>and the Member class</p>
  
  <pre><code>public class Member
  {
      // instance variables 
      private String name;
      private String id;
      private String pinNumber;
  
  
      /**
       * Constructor for objects of class Member
       */
      public Member(String memberName, String memberId, String memberPinNumber)
      {
          // initialise instance variables
          name = memberName;
          id = memberId;
          pinNumber = memberPinNumber;
      }
  
      public Member()
      {
          // initialise instance variables
          name = "Bob";
          id = "ASD123";
          pinNumber = "5678";
      }
  
      //Accessor Methods
      public String getName()
      {
          return name;
      }
  
      public String getId()
      {
          return id;
      }
  
      public String getPinNumber()
      {
          return pinNumber;
      }
  
      //Mutator Methods
      public void newName(String newMemberName)
      {
          name = newMemberName;
      }
  
      public void newId(String newMemberId)
      {
          name = newMemberId;
      }
  
      public void newPinNumber(String newMemberPinNumber)
      {
          name = newMemberPinNumber;
      }
  }
  </code></pre>
  
  <p>I have been told to keep the variable at the top private and use pointers? Not sure what this means but it has not been explained to me very well.</p>