static void Main(string[] args) { ClaimRepository claimRepo = new ClaimRepository(); Queue <Claim> claimQueue = claimRepo.GetClaims(); string response = null; while (response != "4") { Console.Clear(); Console.Write($"Which action would you like to take?" + $"\n1. View all claims." + $"\n2. Process next claim." + $"\n3. Enter new claim." + $"\n4. Exit." + $"\n "); response = Console.ReadLine(); claimQueue = claimRepo.GetClaims(); if (response == "1") { Console.Clear(); Console.WriteLine($"ClaimID\t " + $"Type\t" + $"Description\t" + $"Amount\t" + $"DateOfAccident\t" + $"DateOfClaim\t" + $"IsValid"); foreach (Claim claim in claimQueue) { Console.WriteLine($" {claim.ClaimID}\t " + $"{claim.ClaimType}\t" + $"{claim.Description}\t\t" + $"${claim.ClaimAmount}\t" + $"{claim.DateOfIncident.ToShortDateString()}\t" + $"{claim.DateOfClaim.ToShortDateString()}\t" + $"{claim.IsValid}"); } } } }
private static void EnterNewClaimOption() { // Gather information from user int ClaimID = int.Parse(Input("Give this Claim an ID#: ")); string ClaimType = Input("What is the claim type (car, house, theft): "); string Description = Input("Give a description of the claim: "); double ClaimAmount = double.Parse(Input("How much is the claim for (no dollar signs): ")); DateTime DateOfIncident = DateTime.Parse(Input("What was the date of the incident (MM/DD/YYYY): ")); DateTime DateOfClaim = DateTime.Parse(Input("What was the date of the claim (MM/DD/YYYY): ")); // Create a new claim object using user input and add it to the claim list Claim new_claim = new Claim(ClaimID, ClaimType, Description, ClaimAmount, DateOfIncident, DateOfClaim); ClaimRepository.AddClaimToList(new_claim); Console.WriteLine($"This claim is {(new_claim.IsValid ? "" : "not ")}valid."); Console.WriteLine(); Console.WriteLine("The new claim has been added!"); Input("Press enter/return "); }
static void Main(string[] args) { ClaimRepository claimRepo = new ClaimRepository(); Queue <Claims> claimQueue = claimRepo.ReturnClaims(); bool isRunning = true; while (isRunning) { Console.Clear(); Console.WriteLine("Menu"); Console.WriteLine("1. See Claims\n2.Take Care Of Claims\n3.Input New Claim\n4.Exit"); int input = int.Parse(Console.ReadLine()); switch (input) { case 1: Console.Clear(); claimRepo.ReturnClaims(); foreach (Claims claim in claimQueue) { Console.WriteLine($"{claim.ClaimID} \t {claim.ClaimType} \t {claim.Description} \t {claim.ClaimAmount} \t {claim.DateOfAccident} \t {claim.DateOfClaim} \t {claim.IsValid}"); } Console.WriteLine("Please press Enter..."); Console.ReadLine(); break; case 2: Console.Clear(); Console.WriteLine($"{claimQueue.Peek()} \n"); Console.WriteLine("Would you like to take care of this claim? y/n"); var editClaim = Console.ReadLine(); if (editClaim == "y") { claimRepo.RemoveClaim(); } Console.WriteLine("Claim filed, press enter to continue..."); Console.ReadLine(); break; case 3: Console.Clear(); Console.WriteLine("Please enter claim identification number:"); var input2 = Console.ReadLine(); var claimID = int.Parse(input2); Console.WriteLine("Please enter the type of claim: 1-Vehicle, 2-Home, 3-Theft"); string input3 = Console.ReadLine(); int claimType = int.Parse(input3); ClaimTypes claimTypes; if (claimType == 1) { claimTypes = ClaimTypes.Vehicle; } if (claimType == 2) { claimTypes = ClaimTypes.Home; } if (claimType == 3) { claimTypes = ClaimTypes.Theft; } Console.WriteLine("Please write a brief description of the claim:"); var description = Console.ReadLine(); Console.WriteLine("What is the claim ammount?"); var inputAmount = Console.ReadLine(); decimal claimAmount = Decimal.Parse(inputAmount); Console.WriteLine("When did the accident occour? mm/dd/yyyy"); var dateAccident = Console.ReadLine(); Console.WriteLine("When was the accident filed? mm/dd/yyyy"); var dateClaim = Console.ReadLine(); claimRepo.AddClaimsToQueue(claimType); break; //--come back to this!! } } }
static void Main(string[] args) { ClaimRepository claimsRepo = new ClaimRepository(); Claim car = new Claim(1, "car", "car accident", 400, DateTime.Parse("04/25/2018"), DateTime.Parse("04/27/2018")); Claim house = new Claim(2, "home", "house fire", 4000, DateTime.Parse("04/26/2018"), DateTime.Parse("04/28/2018")); Claim theft = new Claim(3, "theft", "stolen pancakes", 4, DateTime.Parse("04/27/2018"), DateTime.Parse("06/01/2018")); claimsRepo.Add(car); claimsRepo.Add(house); claimsRepo.Add(theft); while (true) { Console.WriteLine("Welcome to your claims queue! What would you like to do?\n" + "Press 1: See all Claims.\n" + "Press 2: Take Care of next claim.\n" + "Press 3: Enter a new Claim.\n"); string theAnswer = Console.ReadLine(); if (theAnswer == "1") { foreach (Claim claim in claimsRepo.GetClaimList()) { Console.WriteLine("Here are the details for the next claim:\n" + $"ID Number: {claim.Id}\n" + $"Claim Dept: {claim.Type}\n" + $"Description: {claim.Description}\n" + $"Cost of Claim: {claim.Amount}\n" + $"Incident Date:: {claim.Incident}\n" + $"Date of Reports: {claim.Report}\n" + $"Validity: {claim.isValid}"); } } if (theAnswer == "2") { Queue <Claim> claims = claimsRepo.GetClaimList(); Console.WriteLine("Would you like to deal with this claim now?"); string Answer = Console.ReadLine(); while (true) { if (Answer == "y") { claimsRepo.CurrentClaimFinished(); Console.Clear(); claimsRepo.PrintList(claimsRepo.GetClaimList()); break; } if (Answer == "n") { break; } } } if (theAnswer == "3") { Console.WriteLine("Enter the number of the claim:"); int claimnumber = int.Parse(Console.ReadLine()); Console.WriteLine("Enter the type of claim"); string claimtype = Console.ReadLine(); Console.WriteLine("Enter the description of the claim:"); string claimscription = Console.ReadLine(); Console.WriteLine("Enter the amount of the claim:"); int claimamount = int.Parse(Console.ReadLine()); Console.WriteLine("Enter the date of the incident:"); DateTime claimincident = DateTime.Parse(Console.ReadLine()); Console.WriteLine("Enter the date the claim was filed:"); DateTime claimreport = DateTime.Parse(Console.ReadLine()); Claim userclaim = new Claim(claimnumber, claimtype, claimscription, claimamount, claimincident, claimreport); claimsRepo.Add(userclaim); } } }
static void Main(string[] args) { Claim claim1 = new Claim(1, "Car", "Car Accident", 5000.00, "12/21/2012", "12/31/2012"); Claim claim2 = new Claim(2, "Home", "House Fire", 7500.00, "01/15/2013", "02/24/2013"); Claim claim3 = new Claim(3, "Theft", "Car Theft", 15000.00, "02/12/2013", "04/29/2013"); Claim claim4 = new Claim(4, "Car", "Car Accident", 500.00, "03/19/2013", "04/30/2013"); Claim claim5 = new Claim(5, "Home", "Burst Water Main", 6000.00, "04/06/2013", "06/20/2013"); ClaimRepository claimRepo = new ClaimRepository(); claimRepo.AddToQueue(claim1); claimRepo.AddToQueue(claim2); claimRepo.AddToQueue(claim3); claimRepo.AddToQueue(claim4); claimRepo.AddToQueue(claim5); Queue <Claim> claims = claimRepo.GetQueue(); while (true) { Console.WriteLine("Enter the NUMBER you would like to select:\n" + "1. List All Queued Items\n" + "2. Add Item to Queue\n" + "3. View Next Item in Queue\n" + "4. Remove Item from Queue\n" + "5. Exit Program\n"); string optionAsString = Console.ReadLine(); int option = int.Parse(optionAsString); if (option == 1) { foreach (Claim claim in claims) { Console.WriteLine($"Claim Number: {claim.ClaimID}\n" + $"Claim Type: {claim.ClaimType}\n" + $"Claim Description: {claim.Description}\n" + $"Claim Amount: {claim.ClaimAmount}\n" + $"Date of Incident: {claim.DateOfIncident} \n" + $"Date of Claim: {claim.DateOfClaim} \n" + $"Validity: {claim.IsValid} \n"); } } if (option == 2) { while (true) { Console.WriteLine("Enter a claim ID: "); int claimid = int.Parse(Console.ReadLine()); Console.WriteLine("Enter a claim type: "); string claimtype = Console.ReadLine(); Console.WriteLine("Enter a claim description: "); string claimdescription = Console.ReadLine(); Console.WriteLine("Enter a claim amount: "); double claimamount = Double.Parse(Console.ReadLine()); Console.WriteLine("Enter the incident date: "); string dateofincident = Console.ReadLine(); Console.WriteLine("Enter the claim date: "); string dateofclaim = Console.ReadLine(); Claim userclaim = new Claim(claimid, claimtype, claimdescription, claimamount, dateofincident, dateofclaim); claimRepo.AddToQueue(userclaim); Console.WriteLine("Would you like to add another claim?: y/n"); string response = Console.ReadLine(); response = response.ToLower(); if (response == "y") { } else if (response == "n") { break; } } } if (option == 3) { Claim peekedclaim = claimRepo.LookAtNextItem(); Console.WriteLine($"Claim ID: {peekedclaim.ClaimID}\n" + $"Claim Type: { peekedclaim.ClaimType}\n" + $"Claim Description: {peekedclaim.Description}\n" + $"Claim Amount: {peekedclaim.ClaimAmount}\n" + $"Date of Incident: {peekedclaim.DateOfIncident} \n" + $"Date of Claim: {peekedclaim.DateOfClaim} \n" + $"Validity: {peekedclaim.IsValid} \n"); } if (option == 4) { while (true) { Console.WriteLine("Would you like to finish the first claim? y/n"); string response = Console.ReadLine(); response = response.ToLower(); if (response == "y") { claimRepo.RemoveFromQueue(); } if (response == "n") { } Console.WriteLine("Would you like to finish the next item?: y/n"); string response1 = Console.ReadLine(); response1 = response1.ToLower(); if (response1 == "y") { } if (response1 == "n") { break; } } } if (option == 5) { break; } } }
static void Main(string[] args) { ClaimRepository claimRepo = new ClaimRepository(); DateTime incidentOneTime = new DateTime(2018, 04, 25); DateTime claimOneTime = new DateTime(2018, 04, 27); Claim claimSmith = new Claim(101, "Car", "Car accident on 465", 400.00m, incidentOneTime, claimOneTime, true); claimRepo.AddClaim(claimSmith); bool cont = true; while (cont) { Console.Clear(); Console.WriteLine($"What do you want to do? Please select a number:\n" + $"1) See all claims\n" + $"2) Take care of the next claim\n" + $"3) Enter a new claim\n" + $"4) Exit"); string userAnswer = Console.ReadLine(); switch (userAnswer) { case "1": Console.Clear(); claimRepo.printQueue(); break; case "2": Console.Clear(); Console.SetBufferSize(150, 150); Claim peek = claimRepo.SeeNextClaimInQueue(); Console.SetCursorPosition(0, 0); Console.Write("ID:"); Console.SetCursorPosition(0, 1); Console.Write(peek.ClaimID); //Console.WriteLine($"Claim ID: {peek.ClaimID}\n" + Console.SetCursorPosition(9, 0); Console.Write("Type:"); Console.SetCursorPosition(9, 1); Console.Write(peek.ClaimType); //$"Claim Type: {peek.ClaimType}\n" + Console.SetCursorPosition(20, 0); Console.Write("Description:"); Console.SetCursorPosition(20, 1); Console.Write(peek.ClaimDescription); //$"Claim Description: {peek.ClaimDescription}\n" + Console.SetCursorPosition(47, 0); Console.Write("Amount:"); Console.SetCursorPosition(47, 1); Console.Write(peek.ClaimAmount); //$"Claim Amount: {peek.ClaimAmount}\n" + Console.SetCursorPosition(60, 0); Console.Write("Date of Incident:"); Console.SetCursorPosition(60, 1); Console.Write(peek.DateOfIncident.ToShortDateString()); //$"Date of Incident: {peek.DateOfIncident}\n" + Console.SetCursorPosition(83, 0); Console.Write("Date of Claim:"); Console.SetCursorPosition(83, 1); Console.Write(peek.DateOfClaim.ToShortDateString()); //$"Date of Claim: {peek.DateOfClaim}\n" + Console.SetCursorPosition(103, 0); Console.Write("Validity:"); Console.SetCursorPosition(103, 1); Console.Write(peek.IsValidKomodo); //$"Claim Validity: {peek.IsValidKomodo}\n"); Console.WriteLine("\n\nDo you want to be assigned as the agent for this claim? y/n"); string agentAssignment = Console.ReadLine(); if (agentAssignment == "y") { claimRepo.TakeNextClaim(); Console.WriteLine("You have been assigned as the agent for this claim."); } else { Console.WriteLine("This claim will remain in the queue."); } break; case "3": Console.Clear(); while (true) { bool isValidKomodo = true; Console.Clear(); Console.WriteLine("Enter the Claim ID:"); string claimIDString = Console.ReadLine(); int claimID = Int32.Parse(claimIDString); Console.WriteLine("Enter claim type (Car, Home, or Theft:"); string claimType = Console.ReadLine(); Console.WriteLine("Enter claim description:"); string claimDescription = Console.ReadLine(); Console.WriteLine("Enter amount of damage:"); string claimAmountString = Console.ReadLine(); decimal claimAmount = decimal.Parse(claimAmountString); Console.WriteLine("Enter date of incident (MM/DD/YYYY):"); //how to I manage how DateTime appears? string dateOfIncidentString = Console.ReadLine(); DateTime dateOfIncident = DateTime.Parse(dateOfIncidentString); Console.WriteLine("Enter date of claim:"); //how to I manage how DateTime appears? string dateOfClaimString = Console.ReadLine(); DateTime dateOfClaim = DateTime.Parse(dateOfClaimString); TimeSpan span = new TimeSpan(30, 0, 0, 0); if (dateOfClaim - dateOfIncident <= span) { isValidKomodo = true; } else if (dateOfClaim - dateOfIncident > span) { isValidKomodo = false; Console.WriteLine("I'm sorry, we cannot process your claim because it occurred outside our 30-day claim period."); break; } Claim userInput = new Claim(claimID, claimType, claimDescription, claimAmount, dateOfIncident, dateOfClaim, isValidKomodo); claimRepo.AddClaim(userInput); Console.WriteLine("Thank you! Your claim is being processed."); break; } break; case "4": (cont) = false; Console.Clear(); Console.WriteLine("Goodbye!"); break; default: break; } Console.ReadLine(); } }
static void Main(string[] args) { ClaimRepository claimRepo = new ClaimRepository(); Queue <Claim> ClaimItems = claimRepo.GetClaimsList(); DateTime c1a = new DateTime(2018, 06, 1); DateTime c1b = new DateTime(2018, 06, 20); DateTime c2a = new DateTime(2018, 06, 1); DateTime c2b = new DateTime(2018, 07, 1); DateTime c3a = new DateTime(2018, 06, 29); DateTime c3b = new DateTime(2018, 07, 01); DateTime c4a = new DateTime(2018, 06, 17); DateTime c4b = new DateTime(2018, 06, 22); Claim claim1 = new Claim(1, "Car", "Accident on highway", 450, c1a, c1b); Claim claim2 = new Claim(2, "Truck", "Accident on highway", 450, c2a, c2b); Claim claim3 = new Claim(3, "Car", "Accident on highway", 450, c3a, c3b); Claim claim4 = new Claim(4, "Bus", "Accident on street", 450, c4a, c4b); claimRepo.AddClaimToList(claim1); claimRepo.AddClaimToList(claim2); claimRepo.AddClaimToList(claim3); claimRepo.AddClaimToList(claim4); Console.WriteLine("ClaimID Type \t Description Amount DateOfAccident DateOfClaim IsValid \n "); claimRepo.PrintList(claimRepo.GetClaimsList()); while (true) { Console.WriteLine("Would you like to 1.Add a Claim, 2. Process the current claim, or 3. List all claims?"); string choice = Console.ReadLine(); if (choice == "1") { while (true) { Console.WriteLine("What is the claim ID:"); int claimID = int.Parse(Console.ReadLine()); Console.WriteLine("What is the vechile type:"); string type = Console.ReadLine(); Console.WriteLine("Describe the accident"); string description = Console.ReadLine(); Console.WriteLine("What is amount"); int amount = int.Parse(Console.ReadLine()); Console.WriteLine("What was the date of the accident?"); DateTime dateAccident = DateTime.Parse(Console.ReadLine()); Console.WriteLine("When was the claim filed?"); DateTime dateClaim = DateTime.Parse(Console.ReadLine()); Claim userClaim = new Claim(claimID, type, description, amount, dateAccident, dateClaim); claimRepo.AddClaimToList(userClaim); Console.WriteLine("Do you want to add annother claim?"); string theAnswer = Console.ReadLine(); if (theAnswer == "y") { continue; } else if (theAnswer == "n") { claimRepo.PrintList(claimRepo.GetClaimsList()); break; } } } else if (choice == "2") { while (true) { Console.WriteLine(claimRepo.GetClaimsList().Peek()); Console.WriteLine("Press enter to confirm removal of current claim."); string item = Console.ReadLine(); claimRepo.CurrentClaimFinished(); claimRepo.PrintList(claimRepo.GetClaimsList()); backToPrompt: Console.WriteLine("Do you want to remove another claim? y/n"); string theAnswer = Console.ReadLine(); if (theAnswer == "y") { continue; } else if (theAnswer == "n") { Console.Clear(); claimRepo.PrintList(claimRepo.GetClaimsList()); break; } else { goto backToPrompt; } } } else if (choice == "3") { claimRepo.PrintList(claimRepo.GetClaimsList()); Console.ReadLine(); } } }
static void Main(string[] args) { ClaimRepository claimRepo = new ClaimRepository(); Queue <Claim> claimQueue = claimRepo.GetClaims(); string response = null; while (response != "4") { Console.Clear(); Console.Write($"Which action would you like to take?" + $"\n1. View all claims." + $"\n2. Process next claim." + $"\n3. Enter new claim." + $"\n4. Exit." + $"\n "); response = Console.ReadLine(); claimQueue = claimRepo.GetClaims(); if (response == "1") { Console.Clear(); Console.WriteLine($"ClaimID\t " + $"Type\t" + $"Description\t" + $"Amount\t" + $"DateOfAccident\t" + $"DateOfClaim\t" + $"IsValid"); foreach (Claim claim in claimQueue) { Console.WriteLine($" {claim.ClaimID}\t " + $"{claim.ClaimType}\t" + $"{claim.Description}\t\t" + $"${claim.ClaimAmount}\t" + $"{claim.DateOfIncident.ToShortDateString()}\t" + $"{claim.DateOfClaim.ToShortDateString()}\t" + $"{claim.IsValid}"); } Console.Read(); } else if (response == "2") { Console.Clear(); if (claimQueue.Count != 0) { Claim topItem = claimQueue.Peek(); Console.WriteLine($"Here are the details for the next claim to be handled:\n" + $" ClaimID: {topItem.ClaimID}\n" + $" Type: {topItem.ClaimType}\n" + $" Description: {topItem.Description}\n" + $" Amount: {topItem.ClaimAmount}\n" + $" DateOfIncident: {topItem.DateOfIncident.ToShortDateString()}\n" + $" DateOfClaim: {topItem.DateOfClaim.ToShortDateString()}\n" + $" IsValid: {topItem.IsValid}"); Console.Write("Do you want to deal with this claim now? (y/n): "); string delClaim = Console.ReadLine(); if (delClaim == "y") { claimQueue.Dequeue(); foreach (Claim claim in claimQueue) { claim.ClaimID--; } claimRepo.CountDown(); } } } else if (response == "3") { ClaimType type = ClaimType.Car; string outPut = null; while (true) { Console.Clear(); Console.Write($"{outPut}" + $"Enter the type of claim being made." + $"\n1. Car \n2. Home \n3. Theft \n "); string inType = Console.ReadLine(); if (inType == "1") { type = ClaimType.Car; break; } else if (inType == "2") { type = ClaimType.Home; break; } else if (inType == "3") { type = ClaimType.Theft; break; } else { outPut = "Invalid Input, please try again.\n"; } } Console.Clear(); Console.Write("Enter the claim amount: $"); string claimAmountAsString = Console.ReadLine(); decimal amount = Decimal.Parse(claimAmountAsString); Console.Write("\nEnter a brief description for the claim: "); string desc = Console.ReadLine(); DateTime claimDate = CreateDate("\nEnter the Month, Day, and Year of the claim."); DateTime incidentDate = CreateDate("\nEnter the Month, Day, and Year of the incident."); claimRepo.AddClaim(type, desc, amount, incidentDate, claimDate); } else if (response == "4") { break; } } }
public static void ChooseAnOption() { while (true) { Console.WriteLine(divider); Console.WriteLine("What would you like to do?"); Console.WriteLine(" [1] Enter a new Claim"); Console.WriteLine(" [2] Address a Claim"); Console.WriteLine(" [3] View Claims"); Console.WriteLine(" [4] Exit program"); while (true) { string choice = Input("Input [#]: "); if (choice == "1") { Console.WriteLine(divider); EnterNewClaimOption(); break; } if (choice == "2") { Console.WriteLine(divider); if (ClaimRepository.GetList().Count > 0) { AddressClaimOption(); } else { Console.WriteLine("You don't have any claims to address."); Input("Press enter/return"); } break; } if (choice == "3") { Console.WriteLine(divider); if (ClaimRepository.GetList().Count > 0) { ViewClaimOption(); } else { Console.WriteLine("You don't have any claims to view."); Input("Press enter/return"); } break; } if (choice == "4") { System.Environment.Exit(1); break; } } } }
private static void ViewClaimOption() { // Most of this is just setup so the text is all aligned properly. I couldn't find a simple way to do this so here's what I went with. string header1 = "Claim ID#"; string header2 = "Claim Type"; string header3 = "Description"; string header4 = "Date of Incident"; string header5 = "Date of Claim"; // Get the number of spaces to pad each item with int padding_1 = Math.Max(ClaimRepository.GetList().Max(t => t.ClaimID.ToString().Count()), header1.Count()); int padding_2 = Math.Max(ClaimRepository.GetList().Max(t => t.ClaimType.Count()), header2.Count()); int padding_3 = Math.Max(ClaimRepository.GetList().Max(t => t.Description.Count()), header3.Count()); int padding_4 = Math.Max(ClaimRepository.GetList().Max(t => t.DateOfIncident.ToString("MM/dd/yyyy").Count()), header4.Count()); int padding_5 = Math.Max(ClaimRepository.GetList().Max(t => t.DateOfClaim.ToString("MM/dd/yyyy").Count()), header5.Count()); // Print the header Console.Write(header1); Console.Write(new string(' ', padding_1 - header1.Count())); Console.Write(" | "); Console.Write(header2); Console.Write(new string(' ', padding_2 - header2.Count())); Console.Write(" | "); Console.Write(header3); Console.Write(new string(' ', padding_3 - header3.Count())); Console.Write(" | "); Console.Write(header4); Console.Write(new string(' ', padding_4 - header4.Count())); Console.Write(" | "); Console.Write(header5); Console.Write(new string(' ', padding_5 - header5.Count())); Console.Write(" | "); Console.WriteLine("Valid?"); // Print the claims foreach (Claim claim in ClaimRepository.GetList()) { Console.Write(claim.ClaimID); Console.Write(new string(' ', padding_1 - claim.ClaimID.ToString().Count())); Console.Write(" | "); Console.Write(claim.ClaimType); Console.Write(new string(' ', padding_2 - claim.ClaimType.Count())); Console.Write(" | "); Console.Write(claim.Description); Console.Write(new string(' ', padding_3 - claim.Description.Count())); Console.Write(" | "); Console.Write(claim.DateOfIncident.ToString("MM/dd/yyyy")); Console.Write(new string(' ', padding_4 - claim.DateOfIncident.ToString("MM/dd/yyyy").Count())); Console.Write(" | "); Console.Write(claim.DateOfClaim.ToString("MM/dd/yyyy")); Console.Write(new string(' ', padding_5 - claim.DateOfClaim.ToString("MM/dd/yyyy").Count())); Console.Write(" | "); Console.WriteLine(claim.IsValid); } Console.WriteLine(); Input("Press enter/return when you're finished viewing this list"); }