B1
B1
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MTKPM
//Cau 1
class Car
// Fields
// Properties
{
get { return yearOfManufacture; }
// Default constructor
public Car()
maxSpeed = 0;
numberOfSeats = 0;
yearOfManufacture = 0;
// Parameter constructor
this.maxSpeed = maxSpeed;
this.numberOfSeats = numberOfSeats;
this.yearOfManufacture = yearOfManufacture;
// Input method
MaxSpeed = int.Parse(Console.ReadLine());
NumberOfSeats = int.Parse(Console.ReadLine());
YearOfManufacture = int.Parse(Console.ReadLine());
}
// Output method
//Cau 2
// Field
// Property
// Default constructor
warrantyYears = 0;
// Parameter constructor
this.warrantyYears = warrantyYears;
// Input method
base.Input();
WarrantyYears = int.Parse(Console.ReadLine());
// Output method
base.Output();
Console.WriteLine($"WarrantyYears: {WarrantyYears}");
// Run method
Console.WriteLine("Ford is running");
else
// Cau 3
class Animal
// Fields
// Properties
{
get { return age; }
// Default constructor
public Animal()
name = "Unknown";
age = 0;
weight = 0.0;
// Parameter constructor
this.name = name;
this.age = age;
this.weight = weight;
// Input method
Console.Write("Name: ");
Name = Console.ReadLine();
Console.Write("Age: ");
Age = int.Parse(Console.ReadLine());
Console.Write("Weight(kg): ");
Weight = double.Parse(Console.ReadLine());
// Output method
// Eat method
Console.WriteLine($"{Name} is eating.");
// Cau 4
// Field
// Property
// Default constructor
lionKind = "Unknown";
// Parameter constructor
this.lionKind = lionKind;
// Override Input
base.Input();
LionKind = Console.ReadLine();
// Override Output
base.Output();
// Hunt method
public void Hunt()
Console.WriteLine($"{Name} is hunting.");
// Field
// Property
// Default constructor
whaleKind = "Unknown";
// Parameter constructor
this.whaleKind = whaleKind;
}
// Override Input
base.Input();
WhaleKind = Console.ReadLine();
// Override Output
base.Output();
// Fish method
Console.WriteLine($"{Name} is fishing.");
//Cau 1
cars[i].Input();
car.Output();
// Cau 2
ford1.FordInput();
ford2.FordInput();
ford1.FordOutput();
ford2.FordOutput();
ford1.Run();
Ford.CompareFord(ford1, ford2);
//Cau 3
Console.WriteLine("Enter information:");
animal.Input();
animal.Output();
animal.Eat();
//Cau 4
animals[i].Input();
animals[i].Input();
heaviestAnimal = animal;
heaviestAnimal.Output();
lion.Hunt();
whale.Fish();