Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 6 of 6

Thread: A few fixable errors. Please help :(

  1. #1
    Junior Member
    Join Date
    Oct 2011
    Posts
    2
    My Mood
    Busy
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default A few fixable errors. Please help :(

    So i'm working on a program, which brings up a menu; this is the full question:

    Red Cross clinic requires a new computerized system to keep track of patients appointments and doctors records. Currently appointment information consists of patient name, patient surname, ID, Contact number, doctor, appointment date and time, and whether the patient is insured or not. Information between doctors should include their ID, name, surname, contact no, medical reg no and their specialisation. The application to be developed needs to be able to perform the following functions.
    1. Book a new appointment
    2. Cancel an existing appointment
    3. Change date for an appointment
    4. Add a new doctor
    5. Delete a doctor record
    6. Print all appointments for a particular doctor.
    7. Exit
    You are to develop this application using Console and any necessary classes and methods.
    I have started the program and have 4 classes, (an extra People class because I needed to practice the Inheritance):

    Main: (Red Cross)

     import java.io.*;
    import java.util.*;
    import javax.swing.*;
     
    class RedCrossExample
    {
    	public static ArrayList<Patients> appointmentsList = new ArrayList<Patients>();
    	public static ArrayList<Doctor> DoctList = new ArrayList<Doctor>();
     
    	public static void main(String args[])
    	{
    		int option= 0;
    		while (option !=5)
    		{
    		    Scanner input = new Scanner(System.in);
    			System.out.println("1.Book a new appointment");
    			System.out.println("2. Cancel an existing appointment");
    			System.out.println("3. Change date for an appointment");
    			System.out.println("4.Add a new doctor");
    			System.out.println("5. Delete a doctor record");
    			System.out.println("6.Print all appointments for a particular doctor");
    			System.out.println("7. Exit");
    			option = input.nextInt();
     
                            switch (option)
    		{
    			case 1:
    			{
    			BookApp();
    			break;
    			}
    			case 2:
    			{
    			break;
    			}
    			case 3:
    			{
    			break;
    			}
    			case 4:
    			{
                            AddDoctor();
    			break;
    			}
                            case 5:
                            {
                                break;
                            }
                            case 6:
                            {
                                break;
                            }
                            }
    		}
     
     
    		}
     
     
    	public static void BookApp()
    	{
    	Patients patient = new Patients();
    	Scanner scanner1 = new Scanner(System.in);
    	System.out.println("Name: ");
    	patient.setName(scanner1.next());
    	System.out.println("Surname: ");
    	patient.setSurname(scanner1.next());
    	System.out.println("Doctor: ");
    	patient.setDoctor(scanner1.next());
    	System.out.println("Insurance: ");
    	patient.setinsurance(scanner1.nextLine());
     
    	System.out.println("Appointment Day : ");
    	int day = scanner1.nextInt();
    	System.out.println("Appointment Month: ");
    	int month = scanner1.nextInt();
    	System.out.println("Appointment Year: ");
    	int year = scanner1.nextInt();
    	System.out.println("Appointment Hour: ");
    	int hour = scanner1.nextInt();
    	System.out.println("Appointment Min: ");
    	int min = scanner1.nextInt();
    	Calendar app = Calendar.getInstance();
    	app.set(year, month, day, hour, min);
    	patient.setAppointment(app);
     
    	}
     
            public static void AddDoctor()
            {
            System.out.println("Name: ");
    	doctor.setName(scanner2.next());
    	System.out.println("Surname: ");
    	doctor.setSurname(scanner2.next());
    	System.out.println("ID: ");
    	doctor.setID(scanner2.next());
    	System.out.println("Contact: ");
    	doctor.setContact(scanner2.nextLine());
            System.out.println("Medical Registration: ");
            doctor.setRegistation(scanner2.nextLine())
            System.out.println("Specialization ");
            doctor.setSpecialization(scanner2.nextLine())
     
     
            }
     
     
     
    }


    Persons(for Inheritance):

    import java.io.*;
    import java.util.*;
    import javax.swing.*;
     
    class Persons
    {   
    	public class Person
    	{
    	protected String id;
    	protected String name;
    	protected String surname;
    	protected long contact;
    	}
     
    	public void setName(String name)
    	{
    	this.name = name;
    	}
     
    	public String getName(){
    	return name;
    	}
     
    	public void setSurname(String surname)
    	{
    	this.surname = surname;
    	}
     
    	public String getSurname(){
    	return surname;
    	}
     
    	public void setID(String id)
    	{
    	this.id = id;
    	}
     
    	public String getID(){
    	return id;
    	}
     
    	public void setContact(long contact)
    	{
    	this.contact = contact;
    	}
     
    	public long getContact(){
    	return contact;
    	}
     
    	public Persons
    	{
    	//empty constructor
    	}
     
    	public Persons(String Name, String Surname, String ID, long contacts)
    	{
    		this.name = Name;
    		this.surname = Surname;
    		this.id = ID;
    		this.contact = contacs;
    	}
     
            public String DisplayDetails()
            {
                string details =" ";
                details= "ID: "+this.ID+"Name: "+this.name+"Surname: "+this.surname+"Contact: "+this.contact;
                return details;
     
                   }
    }


    Patients:

    import java.io.*;
    import java.util.*;
    import javax.swing.*;
     
    class Patients
    {   
    	public class patient extends Persons
    	{
     
    	private String doctor;
    	private boolean insurance;
    	private Calendar appointment = Calendar.getInstance();
    	}
     
     
    	public void setDoctor(String doctor)
    	{
    	this.doctor = doctor;
    	}
     
    	public String getDoctor(){
    	return doctor;
    	}
     
    	public void setInsurance(boolean insurance)
    	{
    	this.insurance = insurance;
    	}
     
    	public boolean getInsurance()
    	{
    	return insurance;
    	}
     
    	public void setAppointment(Calendar appointment)
    	{
    	this.appointment = appointment;
    	}
     
    	public Calendar getAppointment()
    	{
    	return appointment;
    	}
     
    	public Patients
    	{
    	//empty constructor
    	}
     
    	public Patients(String Doctor, bool Insurance, Calendar AppDate)
    	{
     
    		this.doctor = Doctor;
    		this.insurance = Insurance;
    		this.appointment = AppDate;
    	}
     
    	public void ChangeAppDate(int day, int month, int year, int hour, int min)
    	{
    	Calendar changedAppointment = Calendar.getInstance();
    	changedAppointment.set(year, month, day, hour, min);
    	this.appointment = changedAppointment;
    	}
     
    	public void DisplayAppDetails()
    	{
    	String Appdetails ="Patient : "+this.name+" "+this.surname+"\nDoctor : "+this.doctor+"\n Appointment Date : " +(day+"/"+month+"/"+year+" - "+min+":"+hour)+"/nInsurance"+insurance);
    	}
     
            @Override
            public String DisplayDetails()
            {
                String details = super.DisplayDetails();
                details = details+"Doctor: "+this.doctor+"Insurance: "+this.insurance+"Appointment: "+this.appointment);
            }
    }

    Doctors:

    import java.io.*;
    import java.util.*;
    import javax.swing.*;
     
    class Patients
    {   
    	public class patient extends Persons
    	{
     
    	private String doctor;
    	private boolean insurance;
    	private Calendar appointment = Calendar.getInstance();
    	}
     
     
    	public void setDoctor(String doctor)
    	{
    	this.doctor = doctor;
    	}
     
    	public String getDoctor(){
    	return doctor;
    	}
     
    	public void setInsurance(boolean insurance)
    	{
    	this.insurance = insurance;
    	}
     
    	public boolean getInsurance()
    	{
    	return insurance;
    	}
     
    	public void setAppointment(Calendar appointment)
    	{
    	this.appointment = appointment;
    	}
     
    	public Calendar getAppointment()
    	{
    	return appointment;
    	}
     
    	public Patients
    	{
    	//empty constructor
    	}
     
    	public Patients(String Doctor, bool Insurance, Calendar AppDate)
    	{
     
    		this.doctor = Doctor;
    		this.insurance = Insurance;
    		this.appointment = AppDate;
    	}
     
    	public void ChangeAppDate(int day, int month, int year, int hour, int min)
    	{
    	Calendar changedAppointment = Calendar.getInstance();
    	changedAppointment.set(year, month, day, hour, min);
    	this.appointment = changedAppointment;
    	}
     
    	public void DisplayAppDetails()
    	{
    	String Appdetails ="Patient : "+this.name+" "+this.surname+"\nDoctor : "+this.doctor+"\n Appointment Date : " +(day+"/"+month+"/"+year+" - "+min+":"+hour)+"/nInsurance"+insurance);
    	}
     
            @Override
            public String DisplayDetails()
            {
                String details = super.DisplayDetails();
                details = details+"Doctor: "+this.doctor+"Insurance: "+this.insurance+"Appointment: "+this.appointment);
            }
    }



    EXTRA INFO: I would like the errors to be solved please, I know that the menu has only 2 options done by now, but I'll work on that later on.
    Thanks ya'll <3


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    4,972
    My Mood
    Hungover
    Thanks
    133
    Thanked 555 Times in 476 Posts

    Default Re: A few fixable errors. Please help :(

    That is waaay too much code for us to wade through. There are hundreds of posts here, and we simply do not have time to be your debugger. Please read the link in my signature on asking questions the smart way, post an SSCCE that demonstrates one problem at a time, and we'll go from there.

    Recommended reading: How to Program (stuck on homework? READ THIS BEFORE POSTING)
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Junior Member
    Join Date
    Oct 2011
    Posts
    2
    My Mood
    Busy
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: A few fixable errors. Please help :(

    Okay you're right, I'll try and solve them and if I don't manage I'll paste smaller snippets

  4. #4
    Member
    Join Date
    Jul 2011
    Posts
    33
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: A few fixable errors. Please help :(

    Yup, get something to run. At level of hello world, if need be. If you go top down, start with a menu which sends persons to commented pseudocode that you then start filling in with real code one option at a time. Bottom up strategy is to take a class like patient and use main() to test it. When functions work, go on to next class. When done, stage interactions in main off the menu.

    A journey of a thousand miles starts with one step. Each must run properly or you crash.

  5. #5
    Grand Poobah
    Join Date
    Mar 2011
    Posts
    1,465
    My Mood
    Grumpy
    Thanks
    0
    Thanked 158 Times in 149 Posts

    Default Re: A few fixable errors. Please help :(

    class Patients
    {   
    	public class patient extends Persons
    	{
    WTF?
    Improving the world one idiot at a time!

  6. #6
    Think of me.... Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Pakistan
    Posts
    1,136
    My Mood
    Grumpy
    Thanks
    20
    Thanked 82 Times in 78 Posts
    Blog Entries
    1

    Default Re: A few fixable errors. Please help :(

    Quote Originally Posted by Junky View Post
    class Patients
    {   
    	public class patient extends Persons
    	{
    WTF?
    May be he is going to understand the concept of Inner classes too.

Similar Threads

  1. help with errors
    By hello_world in forum What's Wrong With My Code?
    Replies: 3
    Last Post: July 9th, 2011, 09:11 PM
  2. Can't fix my own errors
    By mrroberts2u in forum What's Wrong With My Code?
    Replies: 4
    Last Post: April 14th, 2011, 09:20 AM
  3. GUI errors
    By cindisue in forum What's Wrong With My Code?
    Replies: 1
    Last Post: March 30th, 2011, 09:54 AM
  4. Getting errors
    By Nonire in forum What's Wrong With My Code?
    Replies: 7
    Last Post: July 4th, 2010, 12:21 PM
  5. Why am I getting 62 errors?
    By DestinyChick1225 in forum What's Wrong With My Code?
    Replies: 4
    Last Post: July 1st, 2010, 04:41 AM