added new exercices

This commit is contained in:
didier amyot committed 2023-08-21 09:11:33 -04:00
1 parent 6b25e67c49
commit c17800f71a
4 files changed
+96

No files matched your search

+33
View File
@@ -0,0 +1,33 @@
namespace Algorithms.IdCard;
using System;
public class Name
{
private string firstName;
private string lastName;
public Name(string firstName, string lastName)
{
this.firstName = firstName;
this.lastName = lastName;
}
private bool constainsNumber(string word){
string digits = "0123456789";
foreach (char digit in digits){
if(word.IndexOf(digit) != -1){
return true;
}
}
return false;
}
public bool IsValid(){
if(constainsNumber(this.firstName) || constainsNumber(this.lastName)){
return false;
}
return this.firstName.Length > 1 && this.lastName.Length > 1;
}
}