using System;
using [Link];
// Base class
public class Liste<T> { }
// Interface
public interface IComparable
{
int CompareTo(object obj);
}
// Abstract class Client implementing IComparable
public abstract class Client : IComparable
{
public string Adr { get; set; }
public int idCl { get; set; }
public abstract void Affiche();
public int CompareTo(object obj)
{
if (obj == null) return 1;
Client otherClient = obj as Client;
if (otherClient != null)
return [Link]([Link]);
else
throw new ArgumentException("Object is not a Client");
}
}
// Class ClientMoral inheriting from Client
public class ClientMoral : Client
{
public string NomGeran { get; set; }
public string RaisonSociale { get; set; }
public ClientMoral(string adr, int id, string nomGeran, string raisonSociale)
{
[Link] = adr;
[Link] = id;
[Link] = nomGeran;
[Link] = raisonSociale;
}
public override void Affiche()
{
[Link]($"Client Moral: {NomGeran}, {RaisonSociale}");
}
}
// Class ClientPhysique inheriting from Client
public class ClientPhysique : Client
{
public string NomCl { get; set; }
public ClientPhysique(string adr, int id, string nomCl)
{
[Link] = adr;
[Link] = id;
[Link] = nomCl;
}
public override void Affiche()
{
[Link]($"Client Physique: {NomCl}");
}
}
// Class ListeClient inheriting from Liste<Client>
public class ListeClient : Liste<Client>
{
private List<Client> clients = new List<Client>();
public void AfficherListeCl()
{
foreach (var client in clients)
{
[Link]();
}
}
public void AjouterClient(Client c)
{
[Link](c);
}
}
// Main Program
public class Program
{
public static void Main(string[] args)
{
ClientPhysique c1 = new ClientPhysique("Moez's address", 1, "Moez");
ClientMoral c2 = new ClientMoral("ISET's address", 2, "Nom Geran", "ISET");
ListeClient lcl = new ListeClient();
[Link](c1);
[Link](c2);
[Link](); // Sorting by idClient using CompareTo method
[Link](); // Displaying the list of clients
}
}