Solved

Further question about allocting patient to doctor, ( CEHJ, i can post a ghost problem if you would like to solve the point dispute)

Posted on 2004-04-23
152
385 Views
Last Modified: 2006-11-17

i have a further question..
Is there a way I can bring up a list of already entered doctors, when entering a doctors name while creating a new patient.
Or only be allowed to enter the name of a doctor which has been entered.

ps if you would like me to make up a ghost question for your points i will be happy to do so

////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////

import corejava.Console;

public class Patient
{
//attributes

private int ID;
private static int nextID = 1000;
private String name;
private String address;
private String Postcode;
private String Telephone;
private String DateOfBirth;
private String Allergies;
private String doc;


//connecting code to main method
public Patient(String doc, String n, String a, String p, String t, String d, String al){

    this.doc = doc;
    name = n;
    address = a;
    Postcode = p;
    Telephone = t;
    DateOfBirth = d;
    Allergies = al;
    ID = nextID;
    nextID++;
}

public void setdoc(String doc){
    this.doc = doc;
}

public String getName()
{
    return name;
}


public void printDetails(){
//prints out what the patient has entered

    System.out.println("\ndoc >>         " + doc);
    System.out.println("\nID >>          " + ID);
    System.out.println("\nName >>        " + name);
    System.out.println("\nAddress >>     " + address);
    System.out.println("\nPostcode >>    " + Postcode);
    System.out.println("\nTelephone >>   " + Telephone);
    System.out.println("\nDateOfBirth >> " + DateOfBirth);
    System.out.println("\nAllergies >>   " + Allergies);
   }
    public static int getNextID() {
        return nextID;



}
}
////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////


import corejava.*;
import corejava.Console;

public class mainSurgery
{

storePatients sP;
private Patient p;

storeDoctors sD;
private doctor d;

public mainSurgery()
{
    sP = new storePatients(50);


    sD = new storeDoctors(10);

}

    public int showmenu()
    {

           int choice;
           System.out.println("");
           System.out.println("\t *********************  ");
           System.out.println("\t    FixFast Surgery  ");
           System.out.println("\t *********************  ");
           System.out.print("\n[1]Register a new patient");
           System.out.print("\n[2]Register a new Doctor");
           System.out.print("\n[3]Print all patients data");
           System.out.print("\n[4]Find a patient's details");
           System.out.print("\n[5]Remove a patient's details");
           System.out.print("\n[6]Print Doctors details");
           System.out.print("\n[7]Exit the program");
           System.out.println("");
         choice = Console.readInt("\nPlease select one of the above.");
              return choice;
}

public void addPatient()
{

    String name = Console.readString (" Enter your name ");
    String address = Console.readString (" Your full address ");
    String Postcode = Console.readString (" Correct postcode ");
    String Telephone = Console.readString (" Existing telephone number ");
    String DateOfBirth = Console.readString (" Your date of Birth ");
    String Allergies = Console.readString (" Do you suffer from allergies? ");
    String doc = Console.readString (" Please enter your doctor's name");


    Patient p = new Patient( doc, name, address, Postcode, Telephone, DateOfBirth, Allergies);
        System.out.println(" You have been successfully registered");
    sP.addPatient(p);

}

public void addDoctor()
{

    //int ID = Console.readInt (" Please enter your doctor ID  ");
    String name = Console.readString (" Enter your name oh wise one ");
    String address = Console.readString (" Your address ");
    String Postcode = Console.readString (" Your full Postcode ");
    String homeTelephone = Console.readString (" Home telephone No");
    String maximumPatients = Console.readString (" Maximum designated patients ");
    String currentPatients = Console.readString (" Current patients seeing ");


    doctor d = new doctor( name, address, Postcode, homeTelephone, maximumPatients,
    currentPatients);
    sD.addDoctor(d);

    }

public void printDetails()
{
    sP.printDetails();
}

public void printDoctors()
{
    sD.printDoctors();

}

    public void removePatient()
    {
            String name = Console.readString("Name of Patient? ");

            boolean success = sP.removePatient(name);
            if (success)
            {
                System.out.println("Patient deleted");
            }
            else
                System.out.println("Patient not found");
    }

   public void findPatient()
    {
            String name = Console.readString("What name? ");

            Patient p = sP.getPatient(name);
            if (p != null)
            {
                System.out.println("Found");
                p.printDetails();
            }
            else
            System.out.println("Patient has not been found");

    }


    public void chooseOption()
    {
        int choice;
        choice = showmenu();
        while(choice  !=7)
        {
            switch(choice)
            {
                case 1:
                    addPatient();
                    break;
                case 2:
                    addDoctor();
                    break;
                case 3:
                    printDetails();
                    break;
                case 4:
                    findPatient();
                    break;
                case 5:
                    removePatient();
                    break;
                case 6:
                    printDoctors();
                    break;

                default:
                    System.out.println("Your entry has been processed and is invalid. Please try again");

            }
            choice = showmenu();
        }
    }



public static void main(String[] args)
{
        mainSurgery si = new mainSurgery();
    si.chooseOption();

    System.out.print("Thankyou, I hope you have enjoyed your time here at FixFast");

 }
}
0
Comment
Question by:pigmentarts
  • 64
  • 40
  • 31
  • +2
152 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 10898505
The correct way to solve the previous problem is to get the question reopened. Just post a 0 point q to COmmunity Support
0
 
LVL 35

Expert Comment

by:TimYates
ID: 10898517
And remember this time that there is a "Split Points" link above the comment box, so you can split the points between more than one expert

http://www.experts-exchange.com/Programming/Programming_Languages/Java/help.jsp#hi69
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 10898523
The correct way to implement the functionality you want is to have your storeDoctors class implement toString and call that method
0
 
LVL 12

Author Comment

by:pigmentarts
ID: 10898540
heh, well it wasnt my question so i don't know what the title was :P
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 10898542
But i see you have a printDoctors method in that class. You need to call that function
0
 
LVL 12

Author Comment

by:pigmentarts
ID: 10898551

This is my storeDoctors class as it stands,  do you mean i need a new method in there?   What is implement toString..

public class storeDoctors

{

    private doctor theDoctors[];
    private int numDoctors;

    private int currentDoctors;
    private int maximumDoctors;



   public storeDoctors(int capacity)
   {
    theDoctors = new doctor[capacity];
    currentDoctors = 0;
    maximumDoctors = capacity;
}


    public boolean addDoctor(doctor sD)
{
    if (currentDoctors < maximumDoctors)
    {
        theDoctors[currentDoctors] = sD;
        currentDoctors ++;
        return true;
    }
    else
        return false;
}

  public void printDoctors()
    {
        for(int i = 0; i < currentDoctors ; i++)
        {
            theDoctors[i].printDoctors() ;
        }

    }

}
0
 
LVL 12

Author Comment

by:pigmentarts
ID: 10898562
ah yes, I was thinking along those lines but couldn't put it all together in my head.... where do i call the printDoctors()  method
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 10898568
>>do you mean i need a new method in there?  

No you don't. See my last comment - i didn't see you had a printDoctors method before posting. You just need to call it
0
 
LVL 37

Expert Comment

by:zzynx
ID: 10898572
>> Or only be allowed to enter the name of a doctor which has been entered.
If it was an app with a GUI using a combobox containing the existing doctors would be the only good approach.
But it isn't, is it?

0
 
LVL 9

Expert Comment

by:mmuruganandam
ID: 10898586
think of map solution....


map.put(doctorname, doctor); // doctor is an object.  doctorname is string and key for the map


when the doctor name is entered...

check

if (map.containsKey(doctorname))
{
  d = (doctor)map.get(doctorname);
}
else
{
      map.put(doctorname, doc);
}


Regards,
Muruga
0
 
LVL 37

Expert Comment

by:zzynx
ID: 10898591
>> where do i call the printDoctors()  method
Whenever you want the user to see the available doctors ;)
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 10898596
Presumably as the first (or second) statement in addPatient

System.out.println("Add a patient - here are the current available doctors:");
sd.printDoctors(); // or whatever the storeDoctors variable is
0
 
LVL 9

Expert Comment

by:mmuruganandam
ID: 10898617
>> printDoctors()
might help you only in displaying...

That won't help you in avoiding duplicate to the list.
0
 
LVL 37

Expert Comment

by:zzynx
ID: 10898628
Good idea of murugan.

in your storeDoctors class
replace
       private doctor theDoctors[];
by the map

Whenever adding a doctor, put it in the map. (key= doctor's name)
Whenever the user enters a doctor's name you can check - as he said - with map.contains()
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 10898642
To cause the least disruption to your code, i'd suggest you put a containsDoctor method in your class storeDoctors
0
 
LVL 9

Expert Comment

by:mmuruganandam
ID: 10898652
public class mainSurgery
{
  Map doctorsMap = new HashMap();

----
----
----

public boolean addDoctor(doctor sD)
{
    if (currentDoctors < maximumDoctors)
    {
        String doctorName = sD.getDoctorName();
       
        if (map.containsKey(doctorName) == fals)
        {
           map.put(doctorName, sD);
           currentDoctors ++;
           return true;
        }
    }
    else
        return false;
}
0
 
LVL 9

Expert Comment

by:mmuruganandam
ID: 10898654
simple and elegant is the map strategy for a beginner.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 10898666
There is already a container for Doctors. Adding another simply confuses the code. Either

a. redesign it
b. use the less invasive solution i mentioned
0
 
LVL 9

Expert Comment

by:mmuruganandam
ID: 10898683
doctor object does contain another doctor object...

I mean there is no self composition.  one of the doctor object you have to send all the other doctors and check for the same.

That would be code than this map contains approach.
0
 
LVL 37

Expert Comment

by:zzynx
ID: 10898686
It is also better because
- you have no limit to the number of doctors you can have.
- you don't have to specify a max # of doctors you can have

public class storeDoctors {

    private HashMap theDoctors;

   public storeDoctors(int capacity) {
      theDoctors = new HashMap(capacity);
   }

   public boolean addDoctor(doctor sD) {
     theDoctors.put(sD.getName(), sD);
   }

   public void printDoctors() {
    Iterator it = theDoctors.iterator();
    while (it.hasNext()) {
         System.out.println( ((doctor)it.next()).toString() );
    }
}

public boolean doctorAlreadyKnown(doctor sD) {
     return theDoctors.contains(sD.getName());
}

}
0
 
LVL 9

Expert Comment

by:mmuruganandam
ID: 10898696
A correction...

public boolean addDoctor(doctor sD) {
    if (doctorAlreadyKnown(sD))
          theDoctors.put(sD.getName(), sD);
   }


0
 
LVL 12

Author Comment

by:pigmentarts
ID: 10898700
If it was an app with a GUI using a combobox containing the existing doctors would be the only good approach.
But it isn't, is it?

lol no, dont think it is
0
 
LVL 9

Expert Comment

by:mmuruganandam
ID: 10898704
oops...

public boolean addDoctor(doctor sD) {
    if (doctorAlreadyKnown(sD) == false)
          theDoctors.put(sD.getName(), sD);
   }
0
 
LVL 37

Expert Comment

by:zzynx
ID: 10898712
>>  you don't have to specify a max # of doctors you can have

   public storeDoctors(int capacity) {
      theDoctors = new HashMap(capacity);
   }

should be

   public storeDoctors() {
      theDoctors = new HashMap();
   }

And then you see that storeDoctors is indeed just a HashMap
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 10898718
>>It is also better because ...

This is true. If you go down the redesign route, this is a good approach. Make sure it doesn't break your code elsewhere.
0
 
LVL 9

Expert Comment

by:mmuruganandam
ID: 10898729
All the changes he is going to make is only in "storeDoctors", so there won't be any problem and/or break-up.
0
 
LVL 37

Expert Comment

by:zzynx
ID: 10898738
>>public boolean addDoctor(doctor sD) {
>>    if (doctorAlreadyKnown(sD) == false)
>>          theDoctors.put(sD.getName(), sD);
>>   }

Is not really needed, since a map doesn't allow double by nature.
It just overwrites the entry with the new doctor.
But, indeed... maybe you don't want that...
0
 
LVL 9

Expert Comment

by:mmuruganandam
ID: 10898741
pigmentarts,

Whenever you are satisfied with more than one answer, accept one answer and accept other valuable comments as assisted answer if you really think that is worth.

If there are two different ways and both solves the purpose you can go with split points...

0
 
LVL 9

Expert Comment

by:mmuruganandam
ID: 10898745
That is right, he might have given a wrong values except the name.  So it is better to verify the existence and put it to the map.

0
 
LVL 12

Author Comment

by:pigmentarts
ID: 10898755
Hmmm ok, I'm a little confused.  

and yes simple is the way for me.  forgetting about duplicate doctors..

When entering a patients data...name -  sick patient

please choose your doctor from (alfred, spock, Hyde) -  alfred


could i have something like this, where i call up any doctors that i have entered into the array
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 10898756
If you want to go down the route of retaining your original array, just put this method in storeDoctors:

public boolean containsDoctor(doctor d) {
      return Arrays.asList(doctors).contains(d);
}
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 10898766
>>could i have something like this, where i call up any doctors that i have entered into the array

That answer i gave you way back - print them in addPatient
0
 
LVL 9

Expert Comment

by:mmuruganandam
ID: 10898771
In the map, you can easily get the doctor


public doctor getDoctor(String doctorName)
{
   return (doctor)map.get(doctorName);
}


CEHJ,  the reference would be always different

>> Arrays.asList(doctors).contains(d);
This won't work until he writes his own hashCode and/or comparable implementation
0
 
LVL 12

Author Comment

by:pigmentarts
ID: 10898772
This looked quite interesting mmurugan....
I'm thinking I cant just swap this for the addDoctor method i have... :)


public boolean addDoctor(doctor sD)
{
    if (currentDoctors < maximumDoctors)
    {
        String doctorName = sD.getDoctorName();
       
        if (map.containsKey(doctorName) == fals)
        {
           map.put(doctorName, sD);
           currentDoctors ++;
           return true;
        }
    }
    else
        return false;
}
0
 
LVL 12

Author Comment

by:pigmentarts
ID: 10898793
I'm getting worried about this point splitting business now

CEHJ, you are saying i create a new method  

public boolean containsDoctor(doctor d) {
     return Arrays.asList(doctors).contains(d);
}

in storeDoctor

and just call it in main Surgery..where?
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 10898796
>>
CEHJ,  the reference would be always different

>> Arrays.asList(doctors).contains(d);
This won't work until he writes his own hashCode and/or comparable implementation
>>

That must be done anyway, for ANY collection class implementation to work
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 10898818
>>I'm getting worried about this point splitting business now

Don't get worried!

Just first of all can you clarify *exactly* what you want to achieve, as certain things

>>...  forgetting about duplicate doctors..

are a little hazy.


0
 
LVL 37

Expert Comment

by:zzynx
ID: 10898819
I see that in your addPatient() func you just have the doctor's name.
In that case you should have in storeDoctors:

public boolean isDoctorKnown(String name) {
     return theDoctors.contains(name);
}

Then - to answer your original Q - you could write

public void addPatient()
{

    String name = Console.readString (" Enter your name ");
    String address = Console.readString (" Your full address ");
    String Postcode = Console.readString (" Correct postcode ");
    String Telephone = Console.readString (" Existing telephone number ");
    String DateOfBirth = Console.readString (" Your date of Birth ");
    String Allergies = Console.readString (" Do you suffer from allergies? ");
    do {
      String doc = Console.readString (" Please enter your doctor's name");
      if ( !sD.isDoctorKnown(doc) )
        System.out.println(" That doctor is unknown.");
    } while ( !sD.isDoctorKnown(doc) );

    Patient p = new Patient( doc, name, address, Postcode, Telephone, DateOfBirth, Allergies);
        System.out.println(" You have been successfully registered");
    sP.addPatient(p);
}
0
 
LVL 9

Expert Comment

by:mmuruganandam
ID: 10898823
I won't prefer that anyway, because of the compare complications...
0
 
LVL 9

Expert Comment

by:mmuruganandam
ID: 10898840
method that i and zzynx given is perfectly achieves your requirement...
0
 
LVL 37

Expert Comment

by:zzynx
ID: 10898856
>> please choose your doctor from (alfred, spock, Hyde) -  alfred
>> could i have something like this, where i call up any doctors that i have entered into the array

I would stick to the map approach. (why cf. above)
Then
"please choose your doctor from (alfred, spock, Hyde) -  alfred"

is as simple as changing printDoctors() a little bit

public void printDoctors() {
    Iterator it = theDoctors.iterator();
    System.out.print("(");
    while (it.hasNext())
         System.out.print( ((doctor)it.next()).toString() + "," );
    System.out.print(")");
}
0
 
LVL 12

Author Comment

by:pigmentarts
ID: 10898859
I see that in your addPatient() func you just have the doctor's name.
In that case you should have in storeDoctors:


ok this looks good...just add a method to storeDoctor and add to my addPatient menu.

ok with your final approval i will give this a go.... PLese code!! don't break on me now!!!

Where do you guys do this from?  home or in a big building somewhere?
0
 
LVL 12

Author Comment

by:pigmentarts
ID: 10898867
I dont understand the map thing tho ! 8-()
0
 
LVL 37

Expert Comment

by:zzynx
ID: 10898871
>> method that i and zzynx given is perfectly achieves your requirement...
I agree (of course)  
;°)
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 10898880
>>I won't prefer that anyway, because of the compare complications...

mmuruganandam, the point about correct behaviour in collections classes is a relatively advanced one that i was hoping to bring up later, but since you have already, i hope YOU are aware that the correct equals/hashCode implementations are necessary anyway *including Maps*. If you are aware - why are you bringing it up as a reason for not using the container classes that are already in the code?
0
 
LVL 12

Author Comment

by:pigmentarts
ID: 10898883
woah, dont stray from your 5:31AM post   my your up early...i'm all over here in uk
0
 
LVL 12

Author Comment

by:pigmentarts
ID: 10898892
is that why everyones a bit tetcy...go to bed!!
0
 
LVL 37

Expert Comment

by:zzynx
ID: 10898896
>> I dont understand the map thing tho ! 8-()

As murugan, said just replace your storeDoctors class (comment it out) with ours and see what happens...

>> ok with your final approval i will give this a go
Good.
Listening...
0
 
LVL 9

Expert Comment

by:mmuruganandam
ID: 10898920
the map is going to have the doctorName as key.  So there is no need to worry about the contains part.

0
 
LVL 12

Author Comment

by:pigmentarts
ID: 10898942
public boolean isDoctorKnown(String name) {
     return theDoctors.contains(name);
}

error variable theDoctors not found,  i'll type it now to save time when i dont fix it
0
 
LVL 12

Author Comment

by:pigmentarts
ID: 10898948
ahh ok,,, should i have typed that in storeDoctors or storePatients
0
 
LVL 37

Expert Comment

by:zzynx
ID: 10898966
Yes, that's another function of your storeDoctors class
0
 
LVL 9

Expert Comment

by:mmuruganandam
ID: 10898967
change your addDoctor method in storeDoctors...
0
 
LVL 12

Author Comment

by:pigmentarts
ID: 10898970
ahh lol i changed the patient one..ang on
0
 
LVL 12

Author Comment

by:pigmentarts
ID: 10898975
the one you gave me was for the patient, should i just change it for the doctor
0
 
LVL 12

Author Comment

by:pigmentarts
ID: 10898991

huh? I thought i was doing this

I see that in your addPatient() func you just have the doctor's name.
In that case you should have in storeDoctors:

public boolean isDoctorKnown(String name) {
     return theDoctors.contains(name);
}

Then - to answer your original Q - you could write

public void addPatient()
{

    String name = Console.readString (" Enter your name ");
    String address = Console.readString (" Your full address ");
    String Postcode = Console.readString (" Correct postcode ");
    String Telephone = Console.readString (" Existing telephone number ");
    String DateOfBirth = Console.readString (" Your date of Birth ");
    String Allergies = Console.readString (" Do you suffer from allergies? ");
    do {
      String doc = Console.readString (" Please enter your doctor's name");
      if ( !sD.isDoctorKnown(doc) )
        System.out.println(" That doctor is unknown.");
    } while ( !sD.isDoctorKnown(doc) );

    Patient p = new Patient( doc, name, address, Postcode, Telephone, DateOfBirth, Allergies);
        System.out.println(" You have been successfully registered");
    sP.addPatient(p);
}
 
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 10898996
pigmentarts, just to clarify my position on this one:

1. i have given you the way/place  to print your doctors
2. i agree with redesigning your container of doctors if that's acceptable - i'm merely trying to stop spurious reasons being given for not doing it with the existing one. When you use collections classes with your own, your own should implement equals and hashCode
0
 
LVL 37

Expert Comment

by:zzynx
ID: 10899006
>> the one you gave me was for the patient,
those changes in addPatient()?
Yes.

Don't change anything for adding a doctor. That's OK. (if you use the new storeDoctors class)
0
 
LVL 9

Expert Comment

by:mmuruganandam
ID: 10899029
>> i have given you the way/place  to print your doctors

he has to bring up the doctor in place when he enters the patient.  Just printing is not enough for this requirement.

even the array also now been suggested by you.  that is a new one within the code.  since map is going to take the key as doctor name there is no extra effort put in for compare.
0
 
LVL 12

Author Comment

by:pigmentarts
ID: 10899064
:D
0
 
LVL 12

Author Comment

by:pigmentarts
ID: 10899083
Sorry CEHJ i'm getting a little overwhelmed here, i'm understanding things then hearing stuff about hash and
0
 
LVL 12

Author Comment

by:pigmentarts
ID: 10899123
My 5.50 post,   following this i get errors

varibale doc not found and contains(java.lang.String) not found in class doctor.

Do these question ans sessions usually go on this long or am i special....
0
 
LVL 37

Expert Comment

by:zzynx
ID: 10899145
>> I'm getting a little overwhelmed here
Just code our suggestions at your ease and let us know your problems ;)
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 10899151
>>Just printing is not enough for this requirement.

Do you imagine i'm not aware of that?

>>even the array also now been suggested by you...that is a new one within the code

!? So what is this then?:

>>private doctor theDoctors[];
0
 
LVL 12

Author Comment

by:pigmentarts
ID: 10899174

ok thx,

well this is what i've done  in main method

public void addPatient()
{

    String name = Console.readString (" Enter your name ");
    String address = Console.readString (" Your full address ");
    String Postcode = Console.readString (" Correct postcode ");
    String Telephone = Console.readString (" Existing telephone number ");
    String DateOfBirth = Console.readString (" Your date of Birth ");
    String Allergies = Console.readString (" Do you suffer from allergies? ");
    do {
      String doc = Console.readString (" Please enter your doctor's name");
      if ( !sD.isDoctorKnown(doc) )
        System.out.println(" That doctor is unknown.");
    } while ( !sD.isDoctorKnown(doc) );

    Patient p = new Patient( doc, name, address, Postcode, Telephone, DateOfBirth, Allergies);
        System.out.println(" You have been successfully registered");
    sP.addPatient(p);
}

and in my storeDoctor class i have

public class storeDoctors

{

    private doctor theDoctors[];
    private int numDoctors;

    private int currentDoctors;
    private int maximumDoctors;



   public storeDoctors(int capacity)
   {
    theDoctors = new doctor[capacity];
    currentDoctors = 0;
    maximumDoctors = capacity;
}

public boolean isDoctorKnown(String name) {
     return theDoctors.contains(name);
}

    public boolean addDoctor(doctor sD)
{
    if (currentDoctors < maximumDoctors)
0
 
LVL 9

Expert Comment

by:mmuruganandam
ID: 10899183
No more fights CEHJ... totally tired...

pigmentarts,   Can you please put your code along with all the suggested solution and tell us the status....
0
 
LVL 37

Expert Comment

by:zzynx
ID: 10899191
>> Do these question ans sessions usually go on this long or am i special....
As long as needed. :)

>> contains(java.lang.String) not found in class doctor.
????

In your class storeDoctors you should add

public boolean isDoctorKnown(String name) {
     return theDoctors.contains(name);
}

>> varibale doc not found
???

do {
      String doc = Console.readString (" Please enter your doctor's name: "); //<<< here it is
      if ( !sD.isDoctorKnown(doc) )
        System.out.println(" That doctor is unknown.");
    } while ( !sD.isDoctorKnown(doc) );

Can you post your complete storeDoctors class you have + addPatient()?
0
 
LVL 9

Expert Comment

by:mmuruganandam
ID: 10899193
my weekend starts late... ;)
0
 
LVL 37

Expert Comment

by:zzynx
ID: 10899218
That's not the storeDoctors class that I suggested!
Where's that HashMap?
???? 8-O
0
 
LVL 12

Author Comment

by:pigmentarts
ID: 10899231
public class storeDoctors

{

    private doctor theDoctors[];
    private int numDoctors;

    private int currentDoctors;
    private int maximumDoctors;



   public storeDoctors(int capacity)
   {
    theDoctors = new doctor[capacity];
    currentDoctors = 0;
    maximumDoctors = capacity;
}

public boolean isDoctorKnown(String name) {
     return theDoctors.contains(name);
}


    public boolean addDoctor(doctor sD)
{
    if (currentDoctors < maximumDoctors)
    {
        theDoctors[currentDoctors] = sD;
        currentDoctors ++;
        return true;
    }
    else
        return false;
}

  public void printDoctors()
    {
        for(int i = 0; i < currentDoctors ; i++)
        {
            theDoctors[i].printDoctors() ;
        }

    }

}

lolol  you crazy maaan, but i like you
0
 
LVL 12

Author Comment

by:pigmentarts
ID: 10899242
haha, i told you i didnt know about the hash map
0
 
LVL 12

Author Comment

by:pigmentarts
ID: 10899252
where does this go

{
      String doc = Console.readString (" Please enter your doctor's name: "); //<<< here it is
      if ( !sD.isDoctorKnown(doc) )
        System.out.println(" That doctor is unknown.");
    } while ( !sD.isDoctorKnown(doc) );
0
 
LVL 37

Expert Comment

by:zzynx
ID: 10899255
Try this

public class storeDoctors {

    private HashMap theDoctors;

   public storeDoctors() {
      theDoctors = new HashMap();
   }

   public boolean addDoctor(doctor sD) {
       theDoctors.put(sD.getName(), sD);  // <<< I suppose your doctor class has a getName() function?
   }

   public void printDoctors() {
    Iterator it = theDoctors.iterator();
    while (it.hasNext()) {
         System.out.println( ((doctor)it.next()).toString() );
    }
}

public boolean doctorAlreadyKnown(doctor sD) {
     return theDoctors.contains(sD.getName());
}

public boolean isDoctorKnown(String name) {
    return theDoctors.contains(name);
}

}
0
 
LVL 12

Author Comment

by:pigmentarts
ID: 10899264
or does none of it work without the hash maps
0
 
LVL 12

Author Comment

by:pigmentarts
ID: 10899277
this is now my addPatient in mainSurgery


public void addPatient()
{

    String name = Console.readString (" Enter your name ");
    String address = Console.readString (" Your full address ");
    String Postcode = Console.readString (" Correct postcode ");
    String Telephone = Console.readString (" Existing telephone number ");
    String DateOfBirth = Console.readString (" Your date of Birth ");
    String Allergies = Console.readString (" Do you suffer from allergies? ");
    String doc = Console.readString (" Please enter your doctor's name: "); //<<< here it is
      if ( !sD.isDoctorKnown(doc) )
        System.out.println(" That doctor is unknown.");
    } while ( !sD.isDoctorKnown(doc) );



    Patient p = new Patient( doc, name, address, Postcode, Telephone, DateOfBirth, Allergies);
        System.out.println(" You have been successfully registered");
    sP.addPatient(p);

}
0
 
LVL 9

Expert Comment

by:mmuruganandam
ID: 10899281
this one has to work...
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 37

Expert Comment

by:zzynx
ID: 10899286
replace your current storeDoctors class with that one.
0
 
LVL 12

Author Comment

by:pigmentarts
ID: 10899300
taking out the {  mistake above i now have the error

method contains(java.lang.String) not found in class doctor[] at line 21, col 24
0
 
LVL 12

Author Comment

by:pigmentarts
ID: 10899312
replace my storeDoctors class?   with what one
0
 
LVL 37

Expert Comment

by:zzynx
ID: 10899314
addPatient() is OK

Btw: Is showing all valid doctor names really an option? What if there are 20 or 30?
0
 
LVL 12

Author Comment

by:pigmentarts
ID: 10899323
ah ok, just seen another post...so many :P   one min
0
 
LVL 37

Expert Comment

by:zzynx
ID: 10899332
>> with what one?
THIS:

public class storeDoctors {

    private HashMap theDoctors;

   public storeDoctors() {
      theDoctors = new HashMap();
   }

   public boolean addDoctor(doctor sD) {
       theDoctors.put(sD.getName(), sD);  // <<< I suppose your doctor class has a getName() function?
   }

   public void printDoctors() {
    Iterator it = theDoctors.iterator();
    while (it.hasNext()) {
         System.out.println( ((doctor)it.next()).toString() );
    }
}

public boolean doctorAlreadyKnown(doctor sD) {
     return theDoctors.contains(sD.getName());
}

public boolean isDoctorKnown(String name) {
    return theDoctors.contains(name);
}

}
0
 
LVL 12

Author Comment

by:pigmentarts
ID: 10899334
lol yeah it has a get name function
0
 
LVL 12

Author Comment

by:pigmentarts
ID: 10899357
ok hash map not found in sD    at 2 lines

and iterator not found in sD
0
 
LVL 9

Expert Comment

by:mmuruganandam
ID: 10899366
import java.util.*;
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 10899383
Perhaps you can see how sometimes, even if not the best 'textbook solution', simply adding one method to a class is a lot easier ;-)
0
 
LVL 12

Author Comment

by:pigmentarts
ID: 10899395
i put that in sD...i still get the same errors, oh wait, no....

errors are      method iterator() not found in java.util.HashMap
                     methos contains(java.lang.String) not found in.....(above)
0
 
LVL 12

Author Comment

by:pigmentarts
ID: 10899408
i thought i was just adding one method to my sD class..?
0
 
LVL 9

Expert Comment

by:mmuruganandam
ID: 10899410
map.keySet().iterator()

containsKey(
0
 
LVL 12

Author Comment

by:pigmentarts
ID: 10899423
who what where..
0
 
LVL 12

Author Comment

by:pigmentarts
ID: 10899442
import java.util.*;   in   storeDoctor class?
0
 
LVL 9

Expert Comment

by:mmuruganandam
ID: 10899444
replace the iterator() to keySet().iterator()

replace the contains with containsKey
0
 
LVL 9

Expert Comment

by:mmuruganandam
ID: 10899452
>> import java.util.*;   in   storeDoctor class?

The class in which you are using HashMap and Iterator
0
 
LVL 37

Expert Comment

by:zzynx
ID: 10899460
Sorry my fault indeed:

public class storeDoctors {

    private HashMap theDoctors;

   public storeDoctors() {
      theDoctors = new HashMap();
   }

   public boolean addDoctor(doctor sD) {
       theDoctors.put(sD.getName(), sD);  // <<< I suppose your doctor class has a getName() function?
   }

   public void printDoctors() {
    Iterator it = theDoctors.keySet().iterator();
    while (it.hasNext()) {
         System.out.println( (String)it.next() );  // Print out the names
    }
}

public boolean doctorAlreadyKnown(doctor sD) {
     return theDoctors.containsKey(sD.getName());
}

public boolean isDoctorKnown(String name) {
    return theDoctors.containsKey(name);
}

}
0
 
LVL 9

Expert Comment

by:mmuruganandam
ID: 10899484
public boolean doctorAlreadyKnown(doctor sD) {
     return theDoctors.containsKey(sD.getName());
}

public boolean isDoctorKnown(String name) {
    return theDoctors.containsKey(name);
}

This can be further abstracted as


public boolean doctorAlreadyKnown(doctor sD) {
     return isDoctorKnown(sD.getName());
}

public boolean isDoctorKnown(String name) {
    return theDoctors.containsKey(name);
}
0
 
LVL 12

Author Comment

by:pigmentarts
ID: 10899506
getting 'contains'  error..i dont think i've called it anywhere


import java.util.*;
public class storeDoctors {

    private HashMap theDoctors;

   public storeDoctors() {
      theDoctors = new HashMap();
   }

   public boolean addDoctor(doctor sD) {
       theDoctors.put(sD.getName(), sD);
   }

   public void printDoctors() {
    Iterator it = theDoctors.keySet().iterator()     //////this right??
;
    while (it.hasNext()) {
         System.out.println( ((doctor)it.next()).toString() );
    }
}

public boolean doctorAlreadyKnown(doctor sD) {
     return theDoctors.contains(sD.getName());
}

public boolean isDoctorKnown(String name) {
    return theDoctors.contains(name);
}

}


0
 
LVL 9

Expert Comment

by:mmuruganandam
ID: 10899524
public boolean doctorAlreadyKnown(doctor sD) {
     return isDoctorKnown(sD.getName());
}

public boolean isDoctorKnown(String name) {
    return theDoctors.containsKey(name);
}
0
 
LVL 37

Expert Comment

by:zzynx
ID: 10899536
>> Iterator it = theDoctors.keySet().iterator()     //////this right??

Yes it is. theDoctors.keySet() returns all the keys in the map, .iterator() creates an iterator over them.

>> getting 'contains'  error..i dont think i've called it anywhere

Oh no????
public boolean doctorAlreadyKnown(doctor sD) {
     return theDoctors.contains(sD.getName());     // <<<<<<<<<<<<<<<<<<<
}

public boolean isDoctorKnown(String name) {
    return theDoctors.contains(name); /// <<<<<<<<<<<<<<<<<<<<<<<<<<<<
}
0
 
LVL 12

Author Comment

by:pigmentarts
ID: 10899538
print the names of my doctors...

ach,
still getting errors about HashMap and Iterator   not found in storeDoctors
0
 
LVL 37

Expert Comment

by:zzynx
ID: 10899563
>> still getting errors about HashMap and Iterator   not found in storeDoctors
Come on... Can't believe it.

import java.util.*; in your storeDoctors class
0
 
LVL 12

Author Comment

by:pigmentarts
ID: 10899565
still have those errors..not it doesn't get to stage one of loading  /cry
0
 
LVL 9

Expert Comment

by:mmuruganandam
ID: 10899571
in storeDoctor

import java.util.*;

It should be in the top of the storeDoctors class.
0
 
LVL 12

Author Comment

by:pigmentarts
ID: 10899584
public boolean doctorAlreadyKnown(doctor sD) {
     return theDoctors.contains(sD.getName());     // <<<<<<<<<<<<<<<<<<<error     'contains'
}

public boolean isDoctorKnown(String name) {
    return theDoctors.contains(name); /// <<<<<<<<<<<<<<<<<<<<<<<<<<<< error  'contains'
}
0
 
LVL 12

Author Comment

by:pigmentarts
ID: 10899592
import java.util.*;
public class storeDoctors {

    private HashMap theDoctors;

   public storeDoctors() {
      theDoctors = new HashMap();
   }

   public boolean addDoctor(doctor sD) {
       theDoctors.put(sD.getName(), sD);  // <<< I suppose your doctor class has a getName() function?
   }

   public void printDoctors() {
    Iterator it = theDoctors.keySet().iterator();
    while (it.hasNext()) {
         System.out.println( (String)it.next() );  // Print out the names
    }
}

public boolean doctorAlreadyKnown(doctor sD) {
     return theDoctors.contains(sD.getName());
}

public boolean isDoctorKnown(String name) {
    return theDoctors.contains(name);
}

}
0
 
LVL 37

Expert Comment

by:zzynx
ID: 10899602
contains() SHOULD BE containsKey()
0
 
LVL 12

Author Comment

by:pigmentarts
ID: 10899607
System.out.println( (String it.next() alfred, spock));  // Print out the names ------ my doctor names??
0
 
LVL 12

Author Comment

by:pigmentarts
ID: 10899615
ahhhhhhhhhhhhhhhhhhhhhhhh  come on!!!
0
 
LVL 12

Author Comment

by:pigmentarts
ID: 10899619
not that it works yet, one min :)
0
 
LVL 9

Expert Comment

by:mmuruganandam
ID: 10899622
import java.util.*;
public class storeDoctors {

    private HashMap theDoctors;

   public storeDoctors() {
      theDoctors = new HashMap();
   }


   public boolean addDoctor(doctor sD) {
       theDoctors.put(sD.getName(), sD);  
// <<< the method that returns the doctor name in doctor class sD.getName().. change that
   }

   public void printDoctors() {
    Iterator it = theDoctors.keySet().iterator();
    while (it.hasNext()) {
         System.out.println( (String)it.next() );  // Print out the names
    }
}

public boolean doctorAlreadyKnown(doctor sD) {
     return isDoctorKnown(sD.getName());
}

public boolean isDoctorKnown(String name) {
    return theDoctors.containsKey(name);
}

}
0
 
LVL 37

Expert Comment

by:zzynx
ID: 10899635
Phew... what a mess
;°))
0
 
LVL 12

Author Comment

by:pigmentarts
ID: 10899648
public boolean isDoctorKnown(String name) {
    return theDoctors.containsKey(name);

or

public boolean isDoctorKnown(String name) {
    return theDoctors.containsKey()(name);

                                                l
                                                l
0
 
LVL 12

Author Comment

by:pigmentarts
ID: 10899663
phew is right...think how i feel
0
 
LVL 37

Expert Comment

by:zzynx
ID: 10899666
The first
0
 
LVL 9

Expert Comment

by:mmuruganandam
ID: 10899675
Good luck man... i am leaving.. it is already too late for me....
0
 
LVL 37

Expert Comment

by:zzynx
ID: 10899700
you ask the map if it contains the name (being the key)

A hashmap maps a key to an object

Key  (name)          Object
--------------------------------------
McEnroe   ==>     doctor McEnroe's doctor object
Johnson   ==>      docor Johnson's doctor object
...


So, you call the containsKey() with as parameter the name
0
 
LVL 12

Author Comment

by:pigmentarts
ID: 10899705
ok, we maybe there..nearly

i get an error about this so that good.
// <<< the method that returns the doctor name in doctor class sD.getName().. change that

so i change  in doctor class:

public String getName()
{
    return name;
}

to  
public String sD.getName()
{
    return name;
}

0
 
LVL 12

Author Comment

by:pigmentarts
ID: 10899721
getting a ';' error

public String sD.getName()
0
 
LVL 37

Expert Comment

by:zzynx
ID: 10899744
???????????

Show me your doctor class.

0
 
LVL 9

Expert Comment

by:mmuruganandam
ID: 10899758
that may work..
0
 
LVL 12

Author Comment

by:pigmentarts
ID: 10899761
i kinda get it of get it, kinda like an array
0
 
LVL 37

Expert Comment

by:zzynx
ID: 10899767
your doctor class should return the doctor's name. As simple as what.

public String getName() {
    return name;
}

is OK (if name is the variable you store the doctor's name in)
0
 
LVL 12

Author Comment

by:pigmentarts
ID: 10899777
thx mmuruganandam, thx for your wisdom...you should sleep like a baby now :)
0
 
LVL 12

Author Comment

by:pigmentarts
ID: 10899784
import corejava.Console;

public class doctor
{
//attributes
private String name;
private String address;
private String Postcode;
private String homeTelephone;
private String maximumPatients;
private String currentPatients;

public doctor(String n, String a, String p, String h, String m, String c)
{
    name = n;
    address = a;
    homeTelephone = h;
    maximumPatients = m;
    currentPatients = c;

}

public String sD.getName()
{
    return name;
}

public void printDoctors(){
//print doctor details
    System.out.println("\nName >>             " + name);
    System.out.println("\nAddress >>          " + address);
    System.out.println("\nPostcode >>         " + Postcode);
    System.out.println("\nhomeTelephone >>    " + homeTelephone);
    System.out.println("\nmaximumPatients >>  " + maximumPatients);
    System.out.println("\ncurrentPatients >>  " + currentPatients);


}
}


0
 
LVL 9

Expert Comment

by:mmuruganandam
ID: 10899791
import corejava.Console;

public class doctor
{
//attributes
private String name;
private String address;
private String Postcode;
private String homeTelephone;
private String maximumPatients;
private String currentPatients;

public doctor(String n, String a, String p, String h, String m, String c)
{
    name = n;
    address = a;
    homeTelephone = h;
    maximumPatients = m;
    currentPatients = c;

}

public String getName()
{
    return name;
}

public void printDoctors(){
//print doctor details
    System.out.println("\nName >>             " + name);
    System.out.println("\nAddress >>          " + address);
    System.out.println("\nPostcode >>         " + Postcode);
    System.out.println("\nhomeTelephone >>    " + homeTelephone);
    System.out.println("\nmaximumPatients >>  " + maximumPatients);
    System.out.println("\ncurrentPatients >>  " + currentPatients);


}
}
0
 
LVL 9

Expert Comment

by:mmuruganandam
ID: 10899795
use the given doctor class
0
 
LVL 37

Expert Comment

by:zzynx
ID: 10899829
As I told already...


What the hell does

public String sD.getName() {
}

mean? You define a function!
0
 
LVL 12

Author Comment

by:pigmentarts
ID: 10899832
public boolean addDoctor(doctor sD) {   -- method does not return a value

you made a comment saying  // <<< the method that returns the doctor name in doctor class sD.getName().. change that

thats why i changed     getName()   to   sD.getName
0
 
LVL 37

Expert Comment

by:zzynx
ID: 10899853
why did you change

public String getName()

into

public String sD.getName()

?


P.S. You're developing in java for how many hours?
;))))
Just a joke, just a joke.
0
 
LVL 12

Author Comment

by:pigmentarts
ID: 10899859
wondered when i'd start pissin people off :)

problem is when i start using people answers i stop thinking for myself..
0
 
LVL 12

Author Comment

by:pigmentarts
ID: 10899873
lolol, to be honest i'd say i've been developing java for about 2 days now :)  in essence anyway
0
 
LVL 12

Author Comment

by:pigmentarts
ID: 10899892
because i thought u told me tt change it !!
0
 
LVL 37

Expert Comment

by:zzynx
ID: 10899904
FYI:

public boolean addDoctor(doctor sD) {
       theDoctors.put(sD.getName(), sD);      // put the object sD in the map with as key sD.getName()
}

sD stands for a doctor object, not a storeDoctors object, bad name.

For readability reasons better use good variable names:

public boolean addDoctor(doctor doc) {
       theDoctors.put(doc.getName(), doc);
}



0
 
LVL 12

Author Comment

by:pigmentarts
ID: 10899905
ah i see what u were saying now... me thinks
0
 
LVL 37

Expert Comment

by:zzynx
ID: 10899939
>>wondered when i'd start pissin people off :)
It was a joke

>>problem is when i start using people answers i stop thinking for myself..
Don't ever do that!

>> lolol, to be honest i'd say i've been developing java for about 2 days now :)
That's about 16 hours then ;°)))

>> because i thought u told me tt change it !!
It was murugan's comment
0
 
LVL 12

Author Comment

by:pigmentarts
ID: 10899945
I though sD stood formy storeDoctors class :P  so i could link my array to it
0
 
LVL 12

Author Comment

by:pigmentarts
ID: 10899957
ahh hehheh, yeah but you've gotta be like...
Has this guy actually studied java??
0
 
LVL 37

Expert Comment

by:zzynx
ID: 10899978
Funny remark: "arts" in pigmentarts means doctor in Dutch.
0
 
LVL 37

Expert Comment

by:zzynx
ID: 10900024
I'm developing in java every day. (since > 1 year)
0
 
LVL 12

Author Comment

by:pigmentarts
ID: 10900060
Both

 public boolean addDoctor(doctor doc) {
       theDoctors.put(doc.getName(), doc);  gives error of method does not return a value

and

public boolean addDoctor(doctor sD) {
       theDoctors.put(sD.getName(), sD);

give same error of method not returning a value

ok i have a frind interpreting :)   she says i should be putting      this in my mainSurgery  interface
0
 
LVL 12

Author Comment

by:pigmentarts
ID: 10900077
no way, coincedence??  or fate  :)
0
 
LVL 37

Expert Comment

by:zzynx
ID: 10900106
My fault again.

addDoctor() shouldn't return a boolean.

define it as

public void addDoctor( .......... )
          ^
--------+



...typing all those code by head...
0
 
LVL 37

Expert Comment

by:zzynx
ID: 10900118
"void" means the function doesn't return anything
0
 
LVL 12

Author Comment

by:pigmentarts
ID: 10900150
Aww no...now its sayin    constructor storedoctors(int) not found in class storeDoctor

sD = new storeDoctors(10);    from mainSurgery
0
 
LVL 37

Expert Comment

by:zzynx
ID: 10900163
Change that in

sD = new storeDoctors();

you don't have to pass a limit to your constructor.
(I think this should be the last one...)
0
 
LVL 12

Author Comment

by:pigmentarts
ID: 10900179
II cant mix hash map and array.... can i?
0
 
LVL 12

Author Comment

by:pigmentarts
ID: 10900188
wooohooooooooooooooooooo!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
0
 
LVL 12

Author Comment

by:pigmentarts
ID: 10900197
yeeeeeeeeeeeeehaaaaaaaaaaaaaa!!!!!!!!!!!!!!!!!  thx man.. your a top man!

Have a good life man, hope to speak to you again
0
 
LVL 12

Author Comment

by:pigmentarts
ID: 10900213
oh crap one thing.. how do i get  it so when i enter a non existant docotr it will go back to thew start of menu
0
 
LVL 37

Expert Comment

by:zzynx
ID: 10900225
No, no, no. Forget about arrays.

- An array is limited by its initial size, a HashMap can grow as much as needed
- A hashmap takes care of doubles by nature, an array doesn't
- pretty easy to look up by nature
- ...
0
 
LVL 37

Accepted Solution

by:
zzynx earned 500 total points
ID: 10900276
>> how do i get  it so when i enter a non existant docotr it will go back to thew start of menu
Remove the loop in addPatient() and return when needed.

public void addPatient()
{

    String name = Console.readString (" Enter your name ");
    String address = Console.readString (" Your full address ");
    String Postcode = Console.readString (" Correct postcode ");
    String Telephone = Console.readString (" Existing telephone number ");
    String DateOfBirth = Console.readString (" Your date of Birth ");
    String Allergies = Console.readString (" Do you suffer from allergies? ");
    String doc = Console.readString (" Please enter your doctor's name");
    if ( !sD.isDoctorKnown(doc) ) {
        System.out.println(" That doctor is unknown.");
        return;
    }

    Patient p = new Patient( doc, name, address, Postcode, Telephone, DateOfBirth, Allergies);
        System.out.println(" You have been successfully registered");
    sP.addPatient(p);
}

>> your a top man!
Hoping for top points too.
;°)
0
 
LVL 12

Author Comment

by:pigmentarts
ID: 10900312
if i could give u more i would mate, cya round. have a good life
0
 
LVL 37

Expert Comment

by:zzynx
ID: 10900335
Thanks for accepting

>> if i could give u more i would mate
That's enough. You make my weekend ;)

>>cya round
Certainly. Till the next Q.
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now