0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【保険商品管理システムの開発】自動車保険のModelsを作成

Posted at

コード

Models/AutoInsuranceRate.cs
namespace InsuranceProductManager.Models
{
    public class AutoInsuranceRate
    {
        public string VehicleClass { get; set; }   // 車種クラス
        public string AgeGroup { get; set; }       // 年齢区分
        public decimal BaseRate { get; set; }      // 基本料率(%)
        public decimal GenderFactorMale { get; set; }
        public decimal GenderFactorFemale { get; set; }
    }
}
Models/AutoInsuranceCalculationRequest.cs
namespace InsuranceProductManager.Models
{
    public class AutoInsuranceCalculationRequest
    {
        public string VehicleClass { get; set; }
        public string AgeGroup { get; set; } // "全年齢", "21歳以上", "26歳以上"
        public string Gender { get; set; }   // "男性" or "女性"
        public int Grade { get; set; }       // 等級(1~20)
        public int AnnualMileage { get; set; } // 年間走行距離(km)
        public bool IncludeVehicleDamage { get; set; }
        public bool IncludePersonalInjury { get; set; }
        public bool IncludeLawyerService { get; set; }
        public int Years { get; set; }
    }
}
Models/AutoInsuranceCalculationResult.cs
namespace InsuranceProductManager.Models
{
    public class AutoInsuranceCalculationResult
    {
        public decimal AnnualPremium { get; set; }
        public decimal TotalPremium { get; set; }
        public string Details { get; set; }
    }
}

プロパティと get; set;

public string VehicleClass { get; set; }   // 車種クラス

これは「プロパティ」と呼ばれるものです。
プロパティは クラスの外から安全に値を読み書きできる変数のようなもの です。
• get; → 値を取得する(読み取り)
• set; → 値を設定する(書き込み)

たとえば、このプロパティを使うとこうなります:

var rate = new AutoInsuranceRate();
rate.VehicleClass = "普通車";   // ← set による代入
Console.WriteLine(rate.VehicleClass); // ← get による取得
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?