Answer to Question #151731 in C# for Tooba Tariq

Question #151731
National Health Center wants to computerize its patient and employee records system named
HealthPlus (HPC). A patient must register as outdoor and indoor patient and the system needs
to store their name, address and mobile number and date of admission in case of indoor
patients and name, address and mobile number and date of birth in case of outdoor patients.
Each patient is given a unique four-digit patient number. The system will keep a count of how
many patients the HPC currently has.
1
Expert's answer
2020-12-18T04:18:28-0500
using System;
public class HealthPlus {
    int _patientNumber;
    string _name;
    string _adress;
    string _mobileNumber;
    int _day;
    int _month;
    int _year;
    
    //constructor to initalize all the variables
    public HealthPlus (int PatientNumber, string Name, string Adress, string MobileNumber, int Day, int Month, int Year) {
        this._patientNumber = PatientNumber;
        this._name = Name;
        this._adress = Adress;
        this._mobileNumber = MobileNumber;
        this._day = Day;
        this._month = Month;
        this._year = Year;
    }
    public int PatientNumber {
        get {
            return _patientNumber;
        }
        set {
            this._patientNumber = value;
        }
    }
    public void DisplayPatientNumber() {
        Console.WriteLine("Employee Number: {0}", PatientNumber);
    }
    
    public string Name {
        get {
            return _name;
        }
        set {
            this._name = value;
        }
    }
    public void DisplayName() {
        Console.WriteLine("Name: {0}", Name);
    }
    
    public string Adress {
        get {
            return _adress;
        }
        set {
            this._adress = value;
        }
    }
    public void DisplayAdress() {
        Console.WriteLine("Adress: {0}", Adress);
    }
    
    public string MobileNumber {
        get {
            return _mobileNumber;
        }
        set {
            this._mobileNumber = value;
        }
    }
    public void DisplayMobileNumber() {
        Console.WriteLine("Contact Number: {0}", MobileNumber);
    }
    
    public int Day
    {
        get
        {
            return _day;
        }
        set
        {
            this._day = value;
        }
    }
    public void DisplayDay()
    {
        Console.WriteLine("day: {0}", Day); 
    }
    
    public int Month
    {
        get
        {
            return _month;
        }
        set
        {
            this._month = value;
        }
    }
    public void DisplayMonth()
    {
        Console.WriteLine("month: {0}", Month); 
    }
    
    public int Year
    {
        get
        {
            return _year;
        }
        set
        {
            this._year = value;
        }
    }
    public void DisplayYear()
    {
        Console.WriteLine("year: {0}", Year); 
    }


}
class HealthPlusTest {
    public static void Main(string[] args) {
        
        Console.Write("This is for outdoor patients: \n");
        HealthPlus outdoor_patient = new HealthPlus(0, null, null, null, 0, 0, 0);
        Console.Write("Enter patient number: ");
        outdoor_patient.PatientNumber = Convert.ToInt32(Console.ReadLine());
        Console.Write("Enter Name: ");
        outdoor_patient.Name = Convert.ToString(Console.ReadLine());
        Console.Write("Enter Adress: ");
        outdoor_patient.Adress = Convert.ToString(Console.ReadLine());
        Console.Write("Enter Mobile Number: ");
        outdoor_patient.MobileNumber = Convert.ToString(Console.ReadLine());
        Console.Write("Enter a day for admission date: ");
        outdoor_patient.Day = Convert.ToInt32(Console.ReadLine());
        Console.Write("Enter a month for admission date: ");
        outdoor_patient.Month = Convert.ToInt32(Console.ReadLine());
        Console.Write("Enter a year for admission date: ");
        outdoor_patient.Year = Convert.ToInt32(Console.ReadLine());
        
        outdoor_patient.DisplayPatientNumber();
        outdoor_patient.DisplayName();
        outdoor_patient.DisplayAdress();
        outdoor_patient.DisplayMobileNumber();
        outdoor_patient.DisplayDay();
        outdoor_patient.DisplayMonth();
        outdoor_patient.DisplayYear();
        
        
        Console.Write("This is for indoor patients: \n");
        HealthPlus indoor_patient = new HealthPlus(0, null, null, null, 0, 0, 0);
        Console.Write("Enter patient number: ");
        indoor_patient.PatientNumber = Convert.ToInt32(Console.ReadLine());
        Console.Write("Enter Name: ");
        indoor_patient.Name = Convert.ToString(Console.ReadLine());
        Console.Write("Enter Adress: ");
        indoor_patient.Adress = Convert.ToString(Console.ReadLine());
        Console.Write("Enter Mobile Number: ");
        indoor_patient.MobileNumber = Convert.ToString(Console.ReadLine());
        Console.Write("Enter a day for admission date: ");
        indoor_patient.Day = Convert.ToInt32(Console.ReadLine());
        Console.Write("Enter a month for admission date: ");
        indoor_patient.Month = Convert.ToInt32(Console.ReadLine());
        Console.Write("Enter a year for admission date: ");
        indoor_patient.Year = Convert.ToInt32(Console.ReadLine());
        
        indoor_patient.DisplayPatientNumber();
        indoor_patient.DisplayName();
        indoor_patient.DisplayAdress();
        indoor_patient.DisplayMobileNumber();
        indoor_patient.DisplayDay();
        indoor_patient.DisplayMonth();
        indoor_patient.DisplayYear();
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS