This site requires JavaScript, please enable it in your browser!
Greenfoot back
divinity
divinity wrote ...

2022/3/12

Medical Office Management (aka MOM), what is wrong

divinity divinity

2022/3/12

#
I know you all must be tired of me but anyways, I have this programme that I have build but it is not running as it should. It is called Medical Office Management where I have to used inheritance. I build the proram but something is deffinite;ly wrong, when I try to run it gave nothing, just blank and it keep running. the part of the program is working is the exit part. I am going to post all of the classes here so that you guys can take a look through my codes and tell me what is wrong and why it is not working properly. here are the classes. first one is the date the employee should be able to do this: A class variable which stores the number of patients noPat ii. Instance variables patID, first name, last name, phone number, date of birth (Date) and balance, which is used to keep track of any outstanding monies due by the patient. the patient class should be able to do this; A class variable which stores the number of patients noPat ii. Instance variables patID, first name, last name, phone number, date of birth (Date) and balance, which is used to keep track of any outstanding monies due by the patient Date class
package medicalofficemanagement;

import java.text.SimpleDateFormat;
import java.time.Month;

/**
 *
 * @author Luana
 */
public class Date {
    
    private int day;
    private int month;
    private int year;
    
 public Date(){
     this.day = day;
     this.month = month;
     this.year = year;
     
 }
 public Date(int day, int month, int year){
     this.day = day;
     this.month = month;
     this.year = year;
 }
 //accessors and mutators
 public int getday(){
     return day;
 }
 public void setday(int day){
     this.day = day;
 }
 public  int getmonth(){
     return month;
 }
 public void setmonth(int month){
     this.month = month;
 }
 public int getyear(){
     return year;
 }
 public void setyear(int year){
     this.year = year;
 }
    @Override
 public String toString(){
     return String.format("%d/%d/%d",day,month,year);
 }
  the date class should be able to do is: Override your toString to print the date as month/day/year e.g. 10/20/2020
 
}
the employee class
package medicalofficemanagement;

/**
 *
 * @author Luana
 */
public class Employees extends Person{
    
  //variables declared
    private int empnum;
    private double annualsalary;
    
 //no-arg constructor
   public Employees(){
     super();
     this.empnum = empnum;
     this.annualsalary = annualsalary;
     
 }
    //construction with arg
   public Employees(String fname, String lname, int cellnum, int empnum, double annualsalary){
       super(fname,lname,cellnum);
       this.empnum = empnum;
       this.annualsalary = annualsalary;
 }       
       
    public int getempnum(){
       return empnum;
    }
    
    public void setempnum(int empnum){
        this.empnum = empnum;
    }
    public double getannualsalary(){
        return annualsalary;
    }
    public void setannualsalary(double annualsalary){
        this.annualsalary = annualsalary;
    }
    @Override
    public String toString(){
        return String.format("Name is: %s\n cellnum: %d \n empnum: %d\n annualsalary: %.2f",
                             fname, cellnum, empnum, annualsalary);
    }
    
}
the patient class
package medicalofficemanagement;

/**
 *
 * @author Luana
 */
public class Patient extends Person{
    
    //variables declared
    private Date dateofbirth;
    private double balance;
    
  public Patient(){
      super();
      this.dateofbirth = dateofbirth;
      this.balance = balance;
  }
  //constructor with args
  public Patient(String fname, String lname, int cellnum, Date dateofbirth, double balance){
      super(fname, lname,cellnum);
      this.dateofbirth = dateofbirth;
      this.balance = balance;
  }
  //accessors and mutators
  public Date getdateofbirth(){
      return dateofbirth;
  }
  public void setdateofbirth(Date dateofbirth){
      this.dateofbirth = dateofbirth;
  }
  public double getbalance(){
      return balance;
  }
  public void setbalance(double balance){
      this.balance = balance;
  }
  public void amatdue(double totalamt){
      balance= getbalance()+ totalamt;
  }
  //query method to query patient name, date of birth and balance
  
  public String query(){
      return name() +" "+ dateofbirth+ " "+ balance;
  }
  //method for calculating patient bill
  public void patientbill(double totalamt){
      balance = getbalance() + totalamt;
  }
    @Override
 public String toString(){
      return String.format("Patient fname: %s\ncellnum: 1(868)%d:\ndateofbirth:%s\n balance:%.2f", name(), 
                           getcellnum(), dateofbirth, balance);
  }
  
the person class (this class has a specification where u have to put a count (initialize to 0) and a company name of your choice. The person class
package medicalofficemanagement;

/**
 *
 * @author Luana
 */
public class Person {
     
   
    String company = "Chasen Health Care Facility";
    
     int count = 0;
     String fname;
     String lname;
     int cellnum;
    
    //no-args constructor
    
    public Person(){
        this.count = ++ count;
        this.fname = fname;
        this.lname = lname;
    }
    //constructor with args
    
    public Person(String fname, String lname, int cellnum){
        this.count = ++ count;
        this.fname = fname;
        this.lname = lname;
        this.cellnum = cellnum;
    }
    public int getcount(){
        return count;
    }
    public void setcount(int count){
        this.count = count;
    }
    public String getfname(){
        return fname;
    }
    public void setfname(String fname){
        this.fname = fname;
    }
    public String getlname(){
        return lname;
    }
    public void setlname(String lname){
        this.lname = lname;
    }
    public int getcellnum(){
        return cellnum;
    }
    public void setcellnum(int cellnum){
        this.cellnum = cellnum;
    }
    //method to join first and last name
    public String name(){
        return String.format("%s %s \n", fname, lname);
    }
    public String toString(){
        return String.format(name(),"1(868)%d", cellnum);
    }
}  
The main class which is used to run the program, it is call MOM, short for Medical Office Management the main menu
public static void main(String[] args) {
        Scanner keyin = new Scanner(System.in);
        
      // variables declared
      
      char menuChoice, choiceN, choiceS;
      String fname ="", lname="";
      int size=4;
      int empnum=0;
      int cellnum=0;
      int day=0;
      int month=0;
      int year=0;
      int count=0;
      double annualsalary=0;
      double balance=0;
      
      
      //using arraylist for employee, patient and date
      
      ArrayList<Person> person = new ArrayList();
      Employees emp = new Employees(fname, lname,cellnum, empnum, annualsalary);
      Date dateofbirth = new Date(day,month,year);
      Patient patient = new Patient(fname, lname, cellnum, dateofbirth,balance);
      
      //user input for the menu
      System.out.println("Main Menu");
      System.out.println("N - Create a new record");
      System.out.println("S - Select a patient account");
      System.out.println("P - Payments");
      System.out.println("X - Exit program");
      menuChoice = keyin.next().charAt(0);
      
      while(menuChoice != 'X'){
          
          switch(menuChoice){
              case 'N': System.out.println("e - New employee\np - New patient");
              choiceN = keyin.next().charAt(0);
             
              System.out.println(" ");
             
              // break;
              
          switch(choiceN){
              case 'e': System.out.println("Enter the employee firstn name");
                        fname = keyin.next();
                        emp.setfname(fname);
              
                        System.out.println("Enter employee last name");
                        lname = keyin.next();
                        emp.setlname(lname);
              
                        System.out.println("Enter the employee number ");
                        empnum = keyin.nextInt();
                        emp.setempnum(empnum);
              
                        System.out.println("Enter employee cell number");
                        cellnum = keyin.nextInt();
                        emp.setcellnum(cellnum);
              
                        System.out.println("Enter employee annual salary");
                        annualsalary = keyin.nextDouble();
                        emp.setannualsalary(annualsalary);
              
                        person.add(emp);
              
              break;
              
              case 'P': System.out.println("Enter patient first name");
                        fname = keyin.next();
                        patient.setfname(fname);
              
                        System.out.println("Enter patient last name");
                        lname = keyin.next();
                        patient.setlname(lname);
              
                        System.out.println("Enter the patient date of birth");
                        day = keyin.nextInt();
                        patient.setdateofbirth(dateofbirth);
              
                        System.out.println("Enter the patient month of birth");
                        month = keyin.nextInt();
                        patient.setdateofbirth(dateofbirth);
              
                        System.out.println("Enter the patient year of birth");
                        year = keyin.nextInt();
                        patient.setdateofbirth(dateofbirth);
                        person.indexOf(dateofbirth);// pull the matching value of the patient date of birth
              
                        System.out.println("Enter patient cell number");
                        cellnum = keyin.nextInt();
                        patient.setcellnum(cellnum);
                        person.indexOf(cellnum);//pull the matching value of the cellnum
              
                        person.add(patient);
              
              default: System.out.println("Enter the correct choice");
              
              
              break;
              
              //use the arraylist to extract the information needed
              
              case 'S': System.out.println("Enter patient first name");
                        fname = keyin.next();
                        
                        System.out.println("Enter patient cell number");
                        cellnum = keyin.nextInt();
                        
                        //this will pull the value that matches the name
                        person.indexOf(fname);
                        person.indexOf(cellnum);//pulls the matching value of the person cellnum from the index
              
                        System.out.println(" ");
                
                        
                        System.out.println("Q-query\nB -patientbill\nP - payments\nX - exit");
                        
                        choiceS = keyin.next().charAt(0);
                        
                        
                        //switch statement
             switch(choiceS){
                    
                    //printing patient full name, balance and date of birth
             case'Q':   System.out.println(patient.query());
                        
            }
             break;
             
             //request the transaction which shows the amount and add the value to it
              case 'B': System.out.println("Enter transaction total amount");
                        double totalamt = keyin.nextDouble();
                        patient.patientbill(totalamt);
              break;
              
              case 'p': System.out.println("Enter payment total amount");
                        totalamt = keyin.nextDouble();
                        patient.payments(totalamt);
                        
              case 'X': System.out.println("Return to the main menu");
              
                        System.out.println("Correct information is needed");
              
          }
            //paying of the employees salaries
              case 'P': for(int i = 0; i<size; i++){
                        double salaries = emp.getannualsalary()+ balance *0.10;
                 
            break;
            
            //time to exit the program
            
              }
              default: System.out.println();    
        }
    }
              
        
 }
    

}
can someone tell me where i have gone wrong, why it is not working properly. can u gave me some ideas and how to fix it
You need to login to post a reply.