VINParser.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Text.RegularExpressions;
  6. using System.Threading.Tasks;
  7. namespace VINCheckLibrary
  8. {
  9. public class VINParser
  10. {
  11. static void Main(string[] args)
  12. {
  13. }
  14. public static string Parse(string VIN)
  15. {
  16. Regex regex = new Regex("^[A-HJ-NPR-Z0-9]{17}$");
  17. bool isLargeManufacturer = VIN[2] == '9';
  18. Regions parsedRegion = new Regions(VIN.Substring(0, 2));
  19. Years parsedYear = new Years(VIN[9]);
  20. Weight weight = new Weight();
  21. if (weight.CheckWeight(VIN) && regex.IsMatch(VIN))
  22. {
  23. return ("VIN: " + VIN + "\n" +
  24. "WMI: " + VIN.Substring(0, 3)) + "\n" +
  25. "VDS: " + VIN.Substring(3, 6) + "\n" +
  26. "VIS: " + VIN.Substring(9) + "\n" +
  27. "Region: " + parsedRegion.Region + "\n" +
  28. "Country: " + parsedRegion.Country + "\n" +
  29. "Year: " + parsedYear.Year + "\n" +
  30. (isLargeManufacturer ? "less" : "more") +
  31. " than 500 vehicles per year";
  32. }
  33. else return "Incorrect VIN!";
  34. }
  35. }
  36. }