Advertisement
Guest User

Untitled

a guest
Nov 10th, 2017
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.48 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace BookNotes
  8. {
  9. class User
  10. {
  11. string login;
  12. string password;
  13. List<Note> notes;
  14.  
  15. public User(string _login, string _password)
  16. {
  17. login = _login;
  18. password = _password;
  19. }
  20.  
  21. public string Login
  22. {
  23. get
  24. {
  25. return login;
  26. }
  27. }
  28.  
  29. public string Password
  30. {
  31. get
  32. {
  33. return password;
  34. }
  35. }
  36.  
  37. public void AddNote(Note note)
  38. {
  39. notes.Add(note);
  40. }
  41.  
  42. public void AddNotes(List<Note> _notes)
  43. {
  44. notes.AddRange(_notes);
  45. }
  46. }
  47.  
  48. class Note
  49. {
  50. string note;
  51. User userId;
  52. Book bookId;
  53.  
  54. public string _Note
  55. {
  56. get
  57. {
  58. return note;
  59. }
  60. set
  61. {
  62. if (note.Length > 0 && note.Length < 750)
  63. {
  64. note = value;
  65. }
  66. }
  67. }
  68. public User _userId
  69. {
  70. get
  71. {
  72. return userId;
  73. }
  74. set
  75. {
  76. userId = value;
  77. }
  78. }
  79. public Book _bookId
  80. {
  81. get
  82. {
  83. return bookId;
  84. }
  85. set
  86. {
  87. bookId = value;
  88. }
  89. }
  90. }
  91. class Book
  92. {
  93. List<Note> notes;
  94. private int bookId;
  95. private static int count;
  96.  
  97. public Note noteS
  98. {
  99. get
  100. {
  101. return notes;
  102. }
  103. }
  104.  
  105. public int idBook
  106. {
  107. get
  108. {
  109. return bookId;
  110. }
  111. }
  112.  
  113. public Book()
  114. {
  115. count++;
  116. bookId = count;
  117. }
  118. public void AddNote(Note note)
  119. {
  120. notes.Add(note);
  121. }
  122. public void AddNotes(List<Note> _notes)
  123. {
  124. notes.AddRange(_notes);
  125. }
  126. }
  127.  
  128.  
  129.  
  130. class System
  131. {
  132. User user;
  133. private static List<User> users = new List<User>();
  134. int status;
  135. public System(User _user)
  136. {
  137. user = _user;
  138. users.Add(user);
  139. }
  140.  
  141. public int CheckId()
  142. {
  143.  
  144. string answ = null;
  145.  
  146. Console.WriteLine("Do you want to Login? \n\t\t Y/N");
  147. string descision = Console.ReadLine();
  148.  
  149. if (descision == "Y" || descision == "y")
  150. {
  151. Console.WriteLine("Enter your user name :");
  152. answ = Console.ReadLine();
  153. Console.WriteLine("Enter Your Password: ");
  154. string userPasw = Console.ReadLine();
  155.  
  156. while (true)
  157. {
  158. if (answ == user.Login && userPasw == user.Password)
  159. {
  160. status = 1;
  161. Console.WriteLine("You are logged");
  162. return status;
  163. break;
  164. }
  165. else
  166. {
  167. Console.WriteLine("User number or password is wrong, repeat your attempt");
  168. }
  169. }
  170. }
  171. else if (answ == "N" || answ == "n")
  172. {
  173. Console.WriteLine("Do you want to complete registration? \n\t\t Y/N");
  174. answ = Console.ReadLine();
  175.  
  176. switch (answ)
  177. {
  178. case "Y":
  179. case "y":
  180. AddUser();
  181. status = 1;
  182. return status;
  183. break;
  184. case "N":
  185. case "n":
  186. Console.WriteLine("You will continue unlogged");
  187. status = 0;
  188. return status;
  189. break;
  190. }
  191. }
  192. }
  193. private int AddUser()
  194. {
  195. string answ = Console.ReadLine();
  196. switch (answ)
  197. {
  198. case "Y":
  199. case "y":
  200. Console.WriteLine("Enter Your Username: ");
  201. string userId = Console.ReadLine();
  202. Console.WriteLine("Enter Your Password: ");
  203. string userPasw = Console.ReadLine();
  204. User noviy = new User(userId, userPasw);
  205. users.Add(noviy);
  206. return status = 1;
  207. break;
  208.  
  209. case "N":
  210. case "n":
  211. return status = 0;
  212. break;
  213. }
  214. }
  215.  
  216. public void StatusChek(int status)
  217. {
  218. if (status == 0)
  219. {
  220. Console.WriteLine("You are not autorized. You may only add and read your own notes");
  221. }
  222. else if (status == 1)
  223. {
  224. Console.WriteLine("You are autorized. You may add notes, read your own notes and notes of other users");
  225. }
  226. }
  227. }
  228.  
  229. class Screener
  230. {
  231. public void ShowAllNotes( List<Note> notes)
  232. {
  233. notes.ForEach(x => { Console.Write(x); });
  234. }
  235. public int ShowBookId(Book book)
  236. {
  237. return book.idBook;
  238. }
  239.  
  240. public void ShowNote (Note note)
  241. {
  242. Console.WriteLine("Записка принадлежит книге с ID {0} \n Записка принадлежит пользователю с ID {1} \n Текст записки: \n {2}", note._bookId, note._userId, note._Note);
  243. }
  244.  
  245.  
  246. }
  247. class Program
  248. {
  249.  
  250. static void Main(string[] args)
  251. {
  252.  
  253. }
  254. }
  255. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement