我已经做到了这一点,但它没有做我需要它做的事可以有人帮助 [英] I have done this but it is not doing what I need it to do can someone help

查看:88
本文介绍了我已经做到了这一点,但它没有做我需要它做的事可以有人帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

创建一个名为PatientDemo的类,执行以下操作:



为Wrightstown医院计费部门创建一个患者类。包括以下获取和设置属性和字段:患者ID号,姓名,年龄和应付医院的金额。

为Patient类添加接受ID,姓名,年龄和金额的构造函数到期。

重写ToString()方法以返回以记录格式打印出的患者的所有详细信息。

使用Patient类作为基类,派生出InsuredPatient类。 InsuredPatient包含患者的所有数据,以及保存保险公司名称的字段以及保险公司将支付的医院账单的百分比。

您还需要此类的构造函数。

您需要在InsuredPatient类中获取并设置这些值。保险金根据下表确定:

保险公司保险公司支付的账单部分

Wrightstown Mutual 80%

Red Umbrella 60 %

所有其他公司25%

覆盖父类ToString()方法以包括保险公司的名称,已支付的百分比以及保险后应付的金额已经适用于该法案。当我运行项目时,除了保险之外,我得到了一切。有人可以告诉我我做错了什么吗?



我尝试了什么:



Create a class named PatientDemo that does the following:

Create a Patient class for Wrightstown Hospital Billing Department. Include the following get and set properties and fields: patient ID number, name, age, and amount due to the hospital.
Add a constructor for the Patient class that accepts ID, name, age, and amount due.
Override the ToString() method to return all the details for a patient printed out in record format.
Using the Patient class as the base class, derive an InsuredPatient class. An InsuredPatient contains all the data of a Patient, plus fields to hold an insurance company name and the percentages of the hospital bill the insurance company will pay.
You will need a constructor for this class as well.
You will need to get and set those values in the InsuredPatient class. Insurance payments are based on the following table:
Insurance Company Portion of the bill paid by insurance company
Wrightstown Mutual 80%
Red Umbrella 60%
All other companies 25%
Override the parent class ToString() method to include the name of the insurance company, the percentage paid, and the amount due after the insurance has been applied to the bill. When i run the project I get everything but % off of the insurance. Can someone tell me what I am doing wrong?

What I have tried:

using System;
public class PatientDemo
{
    public static void Main()
    {
        InsuredPatient[] patient = new InsuredPatient[5];
        int x, y;
        double grandAmountDue = 0;
        bool goodNum;
        for (x = 0; x < patient.Length; ++x)
        {
            patient[x] = new InsuredPatient();
            Console.Write("Enter patient number ");
            patient[x].PatientNumber = Convert.ToInt32(Console.ReadLine());
            goodNum = true;
            for (y = 0; y < x; ++y)
            {
                if (patient[x].Equals(patient[y]))
                    goodNum = false;
            }
            while (!goodNum)
            {
                Console.Write("Sorry, the patient number " +
                   patient[x].PatientNumber + " is a duplicate. " +
                   "\nPlease reenter ");
                patient[x].PatientNumber = Convert.ToInt32(Console.ReadLine());
                goodNum = true;
                for (y = 0; y < x; ++y)
                {
                    if (patient[x].Equals(patient[y]))
                        goodNum = false;
                }
            }
            Console.Write("Enter name ");
            patient[x].Name = Console.ReadLine();
            Console.Write("Enter age ");
            patient[x].Age = Convert.ToInt32(Console.ReadLine());
            Console.Write("Enter insurance company ");
            patient[x].InsCompany = Console.ReadLine();
            Console.Write("Enter amount due ");
            patient[x].AmountDue = Convert.ToDouble(Console.ReadLine());
        }
        Console.WriteLine("\nSummary:\n");
        Array.Sort(patient);
        for (x = 0; x < patient.Length; ++x)
        {
            Console.WriteLine(patient[x].ToString());
            grandAmountDue += patient[x].AmountDue;
        }
        Console.WriteLine("\nAmountDue for all patients is " + grandAmountDue.ToString("C"));
    }

}
class Patient
{
    public Patient(int num, string name, int age, int amt)
    {
        PatientNumber = num;
        Name = name;
        Age = age;
        AmountDue = amt;
    }
    public Patient() : this(9, "ZZZ", 0, 0)
    {
    }
    public int PatientNumber { get; set; }
    public string Name { get; set; }
    public int Age { get; set; }
    public double AmountDue { get; set; }
    public override string ToString()
    {
        return (GetType() + " " + PatientNumber + " " + Name +
           " " + Age + " AmountDue is " + AmountDue.ToString("C"));
    }
    public override bool Equals(Object e)
    {
        bool equal;
        Patient temp = (Patient)e;
        if (PatientNumber == temp.PatientNumber)
            equal = true;
        else
            equal = false;
        return equal;
    }
    public override int GetHashCode()
    {
        return PatientNumber;
    }
}
class InsuredPatient : Patient, IComparable
{
    public const string INSCO1 = "Wrightstown Mutual";
    public const string INSCO2 = "Red Umbrella";
    public const double PCT1 = 0.80;
    public const double PCT2 = 0.60;
    public const double PCT3 = 0.25;
    string insCompany;
    double pctPaid;
    double origAmountDue;
    public InsuredPatient(int num, string name, int age,
      int amt, string co, double pct) :
      base(num, name, age, amt)
    {
        InsCompany = co;
        OrigAmountDue = AmountDue;
        AmountDue = OrigAmountDue - (pctPaid * OrigAmountDue);
    }
    public InsuredPatient() : this(0, "", 0, 0, "", 0)
    {
    }
    public string InsCompany
    {
        get
        {
            return insCompany;
        }
        set
        {
            insCompany = value;
            if (insCompany == INSCO1)
                PctPaid = PCT1;
            else
               if (insCompany == INSCO2)
                PctPaid = PCT2;
            else
                PctPaid = PCT3;
        }
    }
    public double OrigAmountDue
    {
        get
        {
            return origAmountDue;
        }
        set
        {
            origAmountDue = value;
        }
    }
    public double PctPaid
    {
        get
        {
            return pctPaid;
        }
        set
        {
            pctPaid = value;
        }
    }
    public new double AmountDue
    {
        get
        {
            return base.AmountDue;
        }
        set
        {
            origAmountDue = value;
            base.AmountDue = origAmountDue - (pctPaid * origAmountDue);
        }
    }
    public override string ToString()
    {
        string temp = base.ToString();
        temp = temp + "\n   Original total is " + origAmountDue.ToString("C") +
        "\n   " + insCompany + " Insurance Company pays " +
           pctPaid.ToString("P") + "\n So patient owes......................... " +
           AmountDue.ToString("C");
        return temp;
    }
    int IComparable.CompareTo(Object o)
    {
        int returnVal;
        InsuredPatient temp = (InsuredPatient)o;
        if (this.PatientNumber > temp.PatientNumber)
            returnVal = 1;
        else
           if (this.PatientNumber < temp.PatientNumber)
            returnVal = -1;
        else
            returnVal = 0;
        return returnVal;
    }
}

推荐答案

再次阅读说明:

Read the instructions again:
Quote:

覆盖父类ToString()方法,以包括保险公司的名称,已支付的百分比以及保险申请后的到期金额账单。

Override the parent class ToString() method to include the name of the insurance company, the percentage paid, and the amount due after the insurance has been applied to the bill.



你把这个信息添加到哪个班级?


Which class did you add this information to?


这篇关于我已经做到了这一点,但它没有做我需要它做的事可以有人帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆