Remove overrides
This commit is contained in:
parent
0914d32a5a
commit
a7ada9c683
8 changed files with 12 additions and 26 deletions
|
@ -5,11 +5,6 @@ class Product
|
|||
public string Name { get;}
|
||||
public float Price { get;}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return "Name: " + Name + ", Price: " + Price;
|
||||
}
|
||||
|
||||
public Product(string name, float price)
|
||||
{
|
||||
Name = name;
|
||||
|
|
|
@ -45,6 +45,6 @@ for (int i = 0; i < 2; i++)
|
|||
|
||||
foreach (Product product in products)
|
||||
{
|
||||
Console.WriteLine(product);
|
||||
Console.WriteLine($"Name: {product.Name}, Price: {product.Price}");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,11 +5,6 @@ class Person
|
|||
public string Name { get;}
|
||||
public int Age { get;}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return "Name: " + Name + ", Age: " + Age;
|
||||
}
|
||||
|
||||
public Person(string name, int age)
|
||||
{
|
||||
Name = name;
|
||||
|
|
|
@ -36,5 +36,5 @@ var selected = from person in people where person.Age >= minimum && person.Age <
|
|||
|
||||
foreach (Person person in selected)
|
||||
{
|
||||
Console.WriteLine(person);
|
||||
Console.WriteLine($"Name: {person.Name}, Age: {person.Age}");
|
||||
}
|
||||
|
|
|
@ -6,11 +6,6 @@ class Customer
|
|||
public int Age { get;}
|
||||
public string Address { get;}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return "Name: " + Name + ", Age: " + Age + ", Address: " + Address;
|
||||
}
|
||||
|
||||
public Customer(string name, int age, string address)
|
||||
{
|
||||
Name = name;
|
||||
|
|
|
@ -37,7 +37,7 @@ var selected = from customer in customers where customer.Name == name select cus
|
|||
|
||||
foreach (Customer customer in selected)
|
||||
{
|
||||
Console.WriteLine(customer);
|
||||
Console.WriteLine($"Name: {customer.Name}, Age: {customer.Age}, Address: {customer.Address}");
|
||||
}
|
||||
|
||||
var number = selected.Where(customer => customer.Age >= 18).Count();
|
||||
|
|
|
@ -6,11 +6,6 @@ class Owner
|
|||
public string Name { get;}
|
||||
public string Address { get;}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return "Name: " + Name + ", Address: " + Address;
|
||||
}
|
||||
|
||||
public Owner(int id, string name, string address)
|
||||
{
|
||||
Id = id;
|
||||
|
|
|
@ -34,6 +34,12 @@ while (true)
|
|||
}
|
||||
}
|
||||
|
||||
var selected = owners.FirstOrDefault(owner => cars.Any(car => car.Number == number && car.OwnerId == owner.Id));
|
||||
|
||||
Console.WriteLine(selected);
|
||||
try
|
||||
{
|
||||
var selected = owners.First(owner => cars.Any(car => car.Number == number && car.OwnerId == owner.Id));
|
||||
Console.WriteLine($"Name: {selected.Name}, Address: {selected.Address}");
|
||||
}
|
||||
catch (InvalidOperationException)
|
||||
{
|
||||
Console.WriteLine("Not found.");
|
||||
}
|
||||
|
|
Reference in a new issue