You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Ohara_MAUI/Sources/Model/Classes/Bateau.cs

198 lines
7.1 KiB

/// \file Bateau.cs
/// \brief Contient la définition de la classe Bateau.
///
/// La classe Bateau représente les différents bateaux avec leur nom, leur affiliation à un équipage (Implémentation de la classe Equipage), quand on les voit pour la première fois dans le manga et dans l'anime.
///
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
namespace Model.Classes
{
[DataContract(Name = "bateau")]
/// \class Bateau
/// \brief Représente les différents bateaux avec leur nom, leur affiliation ...
///
///La classe Bateau représente les différents bateaux avec leur nom, leur affiliation à un équipage (Implémentation de la classe Equipage), quand on les voit pour la première fois dans le manga et dans l'anime.
public class Bateau : ObjetOhara
{
[DataMember(Name = "nomromanise")]
private string? nomromanise;
/// \property NomRomanise
/// \brief Chaine de caractère représentant du nom romanisé du bateau.
public string? NomRomanise {
get=>nomromanise;
set
{
if(nomromanise == value) return;
nomromanise = value;
OnPropertyChanged();
}
}
[DataMember(Name = "affiliation", EmitDefaultValue = false)]
private Equipage? equipage;
/// \property Affiliation
/// \brief Equipage représentant l'équipage auquel appartient le bateau.
public Equipage? Affiliation {
get=>equipage;
set
{
if(equipage == value) return;
equipage = value;
OnPropertyChanged();
}
}
[DataMember(Name = "premierchap")]
private int premierchap;
/// \property PremierChap
/// \brief Entier représentant le numéro du chapitre où est apparu le bateau.
public int PremierChap
{
get => premierchap;
set
{
if (premierchap == value) return;
premierchap = value;
OnPropertyChanged();
}
}
[DataMember(Name = "premierep")]
private int premierep;
/// \property PremierEp
/// \brief Entier représentant le numéro de l'épisode où est apparu le bateau.
public int PremierEp
{
get => premierep;
set
{
if (premierep == value) return;
premierep = value;
OnPropertyChanged();
}
}
[DataMember(Name = "description")]
private string? description;
/// \property Description
/// \brief Chaine de caractère représentant la description du bateau.
public string? Description
{
get => description;
set
{
if (description == value) return;
description = value;
OnPropertyChanged();
}
}
[DataMember(Name = "caracteristique")]
private string? caracteristique;
/// \property Caracteristique
/// \brief Chaine de caractère représentant les caracteristiques du bateau.
public string? Caracteristique {
get=> caracteristique;
set
{
if(caracteristique == value) return;
caracteristique = value;
OnPropertyChanged();
}
}
/// \brief Constructeur de la classe Bateau sans image.
/// \param nom Le nom du bateau.
/// \param nomRomanise Le nom romanisé du bateau.
/// \param premierChap Le numéro du premier chapitre dans lequel apparait le bateau.
/// \param premierEp Le numéro du premier épisode dans lequel apparait le bateau.
/// \param description La description du bateau
/// \param caracteristique Les caractéristiques du bateau.
public Bateau(string nom, string nomRomanise, int premierChap, int premierEp, string description, string? caracteristique) : base(nom)
{
if (String.IsNullOrEmpty(nomRomanise))
NomRomanise = "";
else
NomRomanise = nomRomanise;
if (premierEp < 0)
{
PremierEp = 0;
}
else
{
PremierEp = premierEp;
}
if (premierChap < 0 )
{
PremierChap = 0;
}
else
{
PremierChap = premierChap;
}
if (String.IsNullOrEmpty(description))
Description = "Description du bateau ...";
else
Description = description;
if (String.IsNullOrEmpty(caracteristique))
Caracteristique = "Caracteristiques du bateau ...";
else
Caracteristique = caracteristique;
}
/// \brief Constructeur de la classe Bateau avec image.
/// \param nom Le nom du bateau.
/// \param nomRomanise Le nom romanisé du bateau.
/// \param premierChap Le numéro du premier chapitre dans lequel apparait le bateau.
/// \param premierEp Le numéro du premier épisode dans lequel apparait le bateau.
/// \param description La description du bateau
/// \param caracteristique Les caractéristiques.
/// \param image Le nom de l'image du bateau.
public Bateau(string nom, string nomRomanise, int premierChap, int premierEp, string description, string caracteristique, string image) : this(nom, nomRomanise, premierChap, premierEp, description, caracteristique)
{
if (String.IsNullOrEmpty(image))
image = "baseimage.png";
Image = image;
}
/// \brief Renvoie un booléen permettant de savoir si deux bateaux sont égaux.
/// \param obj bateau à comparer.
/// \return bool Booléen exprimant l'égalité ou non.
public override bool Equals(object? obj)
{
if (obj == null) return false;
if (this.GetType() != obj.GetType())
{
return false;
}
else
{
Bateau o = (Bateau)obj;
return o.Nom == Nom;
}
}
public override int GetHashCode()
{
return HashCode.Combine(NomRomanise, Affiliation, PremierChap, PremierEp, Description, Caracteristique);
}
public override string ToString()
{
return "Bateau : " + Nom +" "+EstFavori +" " + NomRomanise + " " + Affiliation + " " + PremierChap + " " + PremierEp + " " + Description + " " + Caracteristique +" "+ Image;
}
}
}