Question

In: Computer Science

Hello I need this written in C# with a few comments thanks Modify the Patient class...

Hello I need this written in C# with a few comments thanks

Modify the Patient class to reference a demographic object that contains the patient phone number, email and next of kin. Create a demographic class to store this information. Make sure to create a constructor in the class for this information.

  1. Modify the Patient constructor to pass in this additional information at the time of instantiation.

  2. Modify the display method to display all the data

  3. HERE IS THE CODE

  4. using System;

    using System.Collections.Generic;

    using System.Linq;

    using System.Text;

    using System.Threading.Tasks;

    namespace Example2Aggregation

    {

        class Program

        {

            static void Main(string[] args)

            {

                Patient p1 = new Patient(1234, "Smith", "Jane", "O", "+");

                displayPatient(p1);

                Patient p2 = new Patient();

                p2.PatientId = 444;

                p2.LastName = "Doe";

                p2.FirstName = "John";

                BloodData b1 = new BloodData("A", "-");

                p2.BloodData = b1;

                p2.displayPatient();

            }

            //display method

            public static void displayPatient(Patient p)

            {

                Console.WriteLine("Patient ID: " + p.PatientId + " " + p.LastName +

                    " Blood Data: " + p.BloodData.BloodType + " " + p.BloodData.RhFactor);

            }

        }

    }



    PATIENT CLASS

    using System;

    using System.Collections.Generic;

    using System.Linq;

    using System.Text;

    using System.Threading.Tasks;


Solutions

Expert Solution

The Program is straight forward as per the requirements. The comments are included in the program wherever applicable.

The new class to hold the demographic information is created and used in the program. The constructors are created as stated in the requirements.

Code

using System;

namespace Test
{
class Program
{
static void Main(string[] args)
{
//Patient1 & Patient2. Provide the details. Here all the values are supplied through the constructor
//The Blood Group related information is also passed in the constructor.
Patient p1 = new Patient(1234, "Smith", "Jane", "O", "+", "888-999-6666", "[email protected]", "Jane", "888-333-444");
//Invoke the Display function which will prints the data on to the screen.
p1.displayPatient();

//Initialise the 2nd patient & display the details
Patient p2 = new Patient(444, "John", "Doe", "A", "-", "888-876-6666", "[email protected]", "Doe", "888-873-444");
p2.displayPatient();

Console.ReadKey();
}

}

class Patient
{
//This class holds the Patient details
private int patientId;
private string firstName;
private string lastName;
private BloodDataWrapper bloodData;
private DemographicWrapper demographicInfo;

public Patient(int patientId, string firstName, string lastName, string bloodType, string rhFactor,
string patientPhoneNumber, string patientEmail, string nextOfKin, string nextOfKinPhoneNumber)
{
this.patientId = patientId;
this.firstName = firstName;
this.lastName = lastName;
this.bloodData = new BloodDataWrapper(bloodType, rhFactor);
this.demographicInfo = new DemographicWrapper(patientPhoneNumber, patientEmail, nextOfKin, nextOfKinPhoneNumber);
}

//display method
public void displayPatient()
{
//Print each of the data in a separate line.
Console.WriteLine("Patient ID: {0}", patientId);
Console.WriteLine("First Name: {0}", firstName);
Console.WriteLine("Last Name: {0}", lastName);
Console.WriteLine("Blood Type: {0}", bloodData.BloodType);
Console.WriteLine("RH factor: {0}", bloodData.RHFactor);
Console.WriteLine("Patient Phone Number: {0}", demographicInfo.PatientPhoneNumber);
Console.WriteLine("Patient Email: {0}", demographicInfo.PatientEmail);
Console.WriteLine("Next Of Kin: {0}", demographicInfo.NextOfKin);
Console.WriteLine("Next Of Kin Phone Number: {0}\n", demographicInfo.NextOfKinPhoneNumber);
}
}
class BloodDataWrapper
{
//This class holds the Blood Group related information
private string bloodType;
private string rhFactor;

public string BloodType { get => bloodType; }
public string RHFactor { get => rhFactor; }

public BloodDataWrapper(string bloodType, string rhFactor)
{
this.bloodType = bloodType;
this.rhFactor = rhFactor;
}
}
class DemographicWrapper
{
//This class holds the demographic information of the patient
private string patientPhoneNumber;
private string patientEmail;
private string nextOfKin;
private string nextOfKinPhoneNumber;
public string PatientPhoneNumber { get => patientPhoneNumber; }
public string PatientEmail { get => patientEmail; }
public string NextOfKin { get => nextOfKin; }
public string NextOfKinPhoneNumber { get => nextOfKinPhoneNumber; }

public DemographicWrapper(string patientPhoneNumber, string patientEmail, string nextOfKin, string nextOfKinPhoneNumber)
{
this.patientPhoneNumber = patientPhoneNumber;
this.patientEmail = patientEmail;
this.nextOfKin = nextOfKin;
this.nextOfKinPhoneNumber = nextOfKinPhoneNumber;
}
}
}


Related Solutions

Hello, I need this is C++. Thank you! (1B) Write a Fraction class whose objects will...
Hello, I need this is C++. Thank you! (1B) Write a Fraction class whose objects will represent Fractions. Note: this is the first part of a multi-part assignment. For this week you should not simplify (reduce) fractions, you should not use "const," and all of your code should be in a single file. In this single file, the class declaration will come first, followed by the definitions of the class member functions, followed by the client program. You must provide...
I need to complete this C++ program. The instructions are in the comments inside the code...
I need to complete this C++ program. The instructions are in the comments inside the code below: ------------------------------------------------------------------------- Original string is: this is a secret! Encypted string is: uijt!jt!b!tfdsfu" Decrypted string is: this is a secret! //Encoding program //Pre-_____? //other necessary stuff here int main() { //create a string to encrypt using a char array cout<< "Original string is: "<<string<<endl; encrypt(string); cout<< "Encrypted string is: "<<string<<endl; decrypt(string); cout<<"Decrypted string is: "<<string<<endl; return 0; } void encrypt(char e[]) { //Write implementation...
Hello I am Raj and I need assistance with this algorithm. Thanks . EX.17-15.ALGO Costs per...
Hello I am Raj and I need assistance with this algorithm. Thanks . EX.17-15.ALGO Costs per Equivalent Unit and Production Costs The following information concerns production in the Forging Department for November. All direct materials are placed into the process at the beginning of production, and conversion costs are incurred evenly throughout the process. The beginning inventory consists of $56,050 of direct materials. ACCOUNT Work in Process—Forging Department ACCOUNT NO. Date Item Debit Credit Balance Debit Credit Nov. 1 Bal.,...
C++ Hello .I need to convert this code into template and then test the template with...
C++ Hello .I need to convert this code into template and then test the template with dynamic array of strings also if you can help me move the function out of the class that would be great.also There is a bug where the memory was being freed without using new operator. I cant seem to find it thanks in advance #include using namespace std; class DynamicStringArray {    private:        string *dynamicArray;        int size;    public:   ...
Hello, I need a summary of the article below. Thanks Why Selfies Do More Harm Than...
Hello, I need a summary of the article below. Thanks Why Selfies Do More Harm Than Good Robert Locke Guess one reason why aliens do not want to visit planet Earth. An obvious one is that the whole planet is addicted to posting selfies on the Internet, so aliens would hardly get a look in! Yesterday morning, a major Italian daily newspaper, which is supposed to be a quality paper, published a selfie of the ex Pope Benedict XVI. It...
Hello, this question relates to a class I am taking called introduction to C++. I have...
Hello, this question relates to a class I am taking called introduction to C++. I have no experience writing programs and outside of learning out of a textbook, and studying on my own, have little understanding of logic. I have been assigned a problem that requires me to write a program for a Grocery Bill, where the consumer inputs the price for 5 items, that the program calculates the total with a 6% sales tax. I really am not sure...
hi,I have this C++ program,can someone add few comments with explanation what is the logic and...
hi,I have this C++ program,can someone add few comments with explanation what is the logic and what is what?thank you I m total beginner #include <iostream> using namespace std; int ArraySum(int MyArray[], int size){ int* p = MyArray; int sum = 0; while(p<MyArray+size){ sum += *p; p++; } return sum; } int main() { int MyArray[10] = {4, 0, 453, 1029, 44, 67, 111, 887, 4003, 1002}; cout<<ArraySum(MyArray,10); return 0; }
1. Modify the HeapIntPriorityQueue class written in this chapter to make it configurable in ways similar...
1. Modify the HeapIntPriorityQueue class written in this chapter to make it configurable in ways similar to Java's PriorityQueue class. Make it possible for the heap to be a min-heap or max-heap. (If you create a heap of objects, you could also modify it to accept a Comparator parameter to its constructor.) (add Comparator sort to provided Heap data structure Class) 2. Change to HeapPriorityQueue with CalendarDate which implements the Comparator interface 3. Modify HeapPriorityQueue to accept a different Comparator,...
I need a randomized quicksort function written in c++ or java with dual pivots and a...
I need a randomized quicksort function written in c++ or java with dual pivots and a partition function
Hello, I need some assistance on completing this program in Pseudocode and in C++ Program 2:...
Hello, I need some assistance on completing this program in Pseudocode and in C++ Program 2: Buh-RING IT! For this assignment, you’re going to simulate a text-based Role-Playing Game (RPG). Design (pseudocode) and implement (source) for a program that reads in 1) the hero’s Hit Points (HP – or health), 2) the maximum damage the hero does per attack, 3) the monster’s HP and 4) the maximum monster’s damage per attack. When the player attacks, it will pick a random...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT