Hi, I am trying to make a simple program which is meant to resemble a hospital patient database.
My aim is that when the user types in a patients name, I want it to type a couple of messages using methods which I have done successfully, for example "searching database". I want the program to then search an array for the patients name, if found, print the patients details/medical history onto the screen.
Here is a sample of what I have got so far, I have been watching tutorials off youtube for guidance:
public class HospitalOne { private String patient; public void setPatient(String name) { patient = name; } public String getPatient() { return patient; } public void details() { System.out.printf("Patient: %s", getPatient()); } public void searching() { System.out.println(""); System.out.println("Searching Database..."); } public String[][] patName[100][10]; patName[0][0] = "Name: Stephen Myhill"; patName[0][1] = "Location: Chesterfield"; patName[0][2] = "D.O.B: 31/2/80"; patName[0][3] = "Medical History:"; }import java.util.Scanner; class MainProgram { public static void main(String[] args) { Scanner input = new Scanner(System.in); HospitalOne col = new HospitalOne(); System.out.println("Enter the name of the patient: "); String tempP = input.nextLine(); col.setPatient(tempP); col.details(); col.searching(); if (col.patName[][].equalsIgnoreCase(tempP)) { } } }
I am getting all kinds of errors but cannot identify and fix them. I don't even know if I am doing this correctly.
My questions are:-
- Where should I be creating my array?
- Should I have a multi-dim array or should I use arrayList?
Thank you for your time.
Regards,
SS.
P.S - bit off topic, but what is wrong with java-forums.org (It is not loading for me anymore. I had a PM from some dude, replied and since then cannot get back on there).