0% found this document useful (0 votes)
11 views3 pages

Actor Management System

The document contains a C# program that manages a list of actors, allowing users to add actors, display them, and sort them by age. It defines an interface for career information and implements classes for actors and cinema stars, including methods for comparison and display. The main program provides a menu-driven interface for user interaction.

Uploaded by

hlessabdelkabir
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views3 pages

Actor Management System

The document contains a C# program that manages a list of actors, allowing users to add actors, display them, and sort them by age. It defines an interface for career information and implements classes for actors and cinema stars, including methods for comparison and display. The main program provides a menu-driven interface for user interaction.

Uploaded by

hlessabdelkabir
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

using System;

using [Link];

// Interface for Comparison


public interface ICarriere
{
DateTime DateDebutCarriere { get; set; }
}

// Class Acteur implementing IComparable


public class Acteur : IComparable<Acteur>
{
public string Nom { get; set; }
public string Prenom { get; set; }
public int Age { get; set; }

public Acteur(string nom, string prenom, int age)


{
Nom = nom;
Prenom = prenom;
Age = age;
}

public int CompareTo(Acteur other)


{
// Compare by Age
if (Age == [Link]) return 0;
return Age > [Link] ? 1 : -1;
}

public override string ToString()


{
return $"{Prenom} {Nom}, Age: {Age}";
}
}

// Class starDeCinema implementing Acteur and ICarriere


public class starDeCinema : Acteur, ICarriere
{
public DateTime DateDebutCarriere { get; set; }

public starDeCinema(string nom, string prenom, int age, DateTime debutCarriere)


: base(nom, prenom, age)
{
DateDebutCarriere = debutCarriere;
}

public override string ToString()


{
return [Link]() + $", Career Start:
{[Link]()}";
}
}

// Main Program
public class Program
{
public static void Main(string[] args)
{
List<Acteur> actors = new List<Acteur>();
bool running = true;

while (running)
{
[Link]("\nMenu:");
[Link]("1. Add an Actor");
[Link]("2. Display Actors");
[Link]("3. Sort and Display Actors (by Age Descending)");
[Link]("4. Exit");
[Link]("Choose an option: ");
int choice = [Link]([Link]());

switch (choice)
{
case 1:
AddActor(actors);
break;
case 2:
DisplayActors(actors);
break;
case 3:
[Link]((a, b) => [Link](a)); // Sort Descending
[Link]("Actors (Sorted by Age Descending):");
DisplayActors(actors);
break;
case 4:
running = false;
break;
default:
[Link]("Invalid choice. Try again.");
break;
}
}
}

static void AddActor(List<Acteur> actors)


{
[Link]("Enter First Name: ");
string prenom = [Link]();
[Link]("Enter Last Name: ");
string nom = [Link]();
[Link]("Enter Age: ");
int age = [Link]([Link]());
[Link]("Is this a Cinema Star? (y/n): ");
string isStar = [Link]().ToLower();

if (isStar == "y")
{
[Link]("Enter Career Start Date (yyyy-MM-dd): ");
DateTime debutCarriere = [Link]([Link]());
[Link](new starDeCinema(nom, prenom, age, debutCarriere));
}
else
{
[Link](new Acteur(nom, prenom, age));
}

[Link]("Actor added successfully!");


}

static void DisplayActors(List<Acteur> actors)


{
if ([Link] == 0)
{
[Link]("No actors to display.");
return;
}

foreach (var actor in actors)


{
[Link](actor);
}
}
}

You might also like