Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. export class Autor {
  2. private _id: number;
  3. private _imie: string;
  4. private _nazwisko: string;
  5. private _email: string;
  6.  
  7. get imie() { return this._imie }
  8. set imie(wartosc: string) {
  9. this._imie = wartosc;
  10. }
  11.  
  12. get nazwisko() { return this._nazwisko }
  13. set nazwisko(wartosc: string) {
  14. this._nazwisko = wartosc;
  15. }
  16.  
  17. get email() { return this._email }
  18. set email(wartosc: string) {
  19. this._email = wartosc;
  20. }
  21.  
  22. constructor(id: number, imie: string, nazwisko: string) {
  23. this._id = id;
  24. this._imie = imie;
  25. this._nazwisko = nazwisko;
  26. //this._email = email;
  27. }
  28. static stworz(id: number, imie: string, nazwisko: string): Autor {
  29. if (imie !== undefined && imie !== null && imie.trim().length > 0) {
  30. throw new Error("imie nie moze byc puste")
  31. }
  32.  
  33. return new Autor(id, imie, nazwisko)
  34. }
  35.  
  36. sprawdzEmail(email: string) {//zmien na static
  37. return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email)
  38. //regexp
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement