Update Lesson 2 Task 4

This commit is contained in:
Stanislav Mykhailenko 2023-03-19 13:15:54 +02:00
parent 31801ad9ce
commit 62266346ac
GPG key ID: 1E95E66A9C9D6A36

View file

@ -26,13 +26,13 @@ do
number = Console.ReadLine(); number = Console.ReadLine();
} while (number == null); } while (number == null);
var selected = owners.FirstOrDefault(x => cars.Any(y => y.Number == number && y.OwnerID == x.ID)); var selected = owners.FirstOrDefault(owner => cars.Any(car => car.Number == number && car.OwnerId == owner.Id));
Console.WriteLine(selected); Console.WriteLine(selected);
class Owner class Owner
{ {
public int ID { get;} public int Id { get;}
public string Name { get;} public string Name { get;}
public string Address { get;} public string Address { get;}
@ -43,7 +43,7 @@ class Owner
public Owner(int id, string name, string address) public Owner(int id, string name, string address)
{ {
ID = id; Id = id;
Name = name; Name = name;
Address = address; Address = address;
} }
@ -52,16 +52,16 @@ class Owner
class Car class Car
{ {
public string Number { get;} public string Number { get;}
public int OwnerID { get;} public int OwnerId { get;}
public override string ToString() public override string ToString()
{ {
return "Number: " + Number + ", Owner ID: " + OwnerID; return "Number: " + Number + ", Owner ID: " + OwnerId;
} }
public Car(string number, int ownerid) public Car(string number, int ownerId)
{ {
Number = number; Number = number;
OwnerID = ownerid; OwnerId = ownerId;
} }
} }