Пример #1
0
 private static void Service(DayService dayService, FamilyService familyService, string line)
 {
     if (DAY_SERVICE_CODE == line.Substring(RI_OF_SERVICE_CODE, RI_SZ_SERVICE_CODE))
     {
         // 昼トク割引
         dayService.Joined();
     }
     else if (FAMILY_SERVICE_CODE == line.Substring(RI_OF_SERVICE_CODE, RI_SZ_SERVICE_CODE))
     {
         // 家族割引 登録されている電話番号を一時保管
         familyService.AppendFamilyTelNumber(line.Substring(RI_OF_SERVICE_OPTION));
     }
 }
Пример #2
0
        public static void Main(string[] args)
        {
            var fis    = new FileStream("../../../record.log", FileMode.Open);
            var reader = new StreamReader(fis);

            var fos    = new FileStream("../../../invoice.dat", FileMode.Create);
            var writer = new StreamWriter(fos);

            writer.NewLine = "\n";

            var invoice       = new Invoice();
            var dayService    = new DayService();
            var familyService = new FamilyService();

            string line = reader.ReadLine();

            while (line != null)
            {
                Console.WriteLine(line);

                if (line.StartsWith(RC_OWNER_INFO))
                {
                    // 契約者情報
                    invoice.SetOwnerTelNumber(line.Substring(RI_OF_OWNER_TEL_NUMBER));
                }
                else if (line.StartsWith(RC_SERVICE_INFO))
                {
                    // 加入サービス情報
                    Service(dayService, familyService, line);
                }
                else if (line.StartsWith(RC_CALL_LOG))
                {
                    // 通話記録
                    Call(invoice, dayService, familyService, line);
                }
                else if (line.StartsWith(RC_SEPARATOR))
                {
                    // 区切り
                    Separate(writer, invoice, dayService, familyService);
                }


                line = reader.ReadLine();
            }

            writer.Close();
            fos.Close();

            reader.Close();
            fis.Close();
        }