Advertisement
Guest User

Untitled

a guest
Jan 26th, 2020
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.85 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace ConsoleApplication1
  7. {
  8. class Program
  9. {
  10. static void Main(string[] args)
  11. {
  12. }
  13. }
  14. class Files
  15. {
  16. private File generetedFile;
  17. private File file1;
  18. private File file2;
  19.  
  20. public Files(File file1, File file2)
  21. {
  22. this.file1 = file1;
  23. this.file2 = file2;
  24. if (file1.Suffix == file2.Suffix)
  25. {
  26. Console.WriteLine("Enter file name:");
  27. string fileName = Console.ReadLine();
  28. file1.Open = true;
  29. file2.Open = true;
  30. generetedFile = new File(fileName, file1.Suffix, file1.SizeInMbs + file2.SizeInMbs, DateTime.Now, file1.Contents + file2.Contents, true);
  31. file1.Open = false;
  32. file2.Open = false;
  33. }
  34. else
  35. {
  36. Console.WriteLine("Files don't share the same sufficx");
  37. }
  38. }
  39.  
  40.  
  41. }
  42. class File
  43. {
  44. private string fileName;
  45. private string suffix;
  46. private double sizeInMbs;
  47. private DateTime dateOfCreation;
  48. private string contents;
  49. private bool open;
  50.  
  51. public File(string fileName, string suffix, double sizeInMbs, DateTime dateOfCreation, string contents, bool open)
  52. {
  53. this.fileName = fileName;
  54. this.suffix = suffix;
  55. this.sizeInMbs = sizeInMbs;
  56. this.dateOfCreation = dateOfCreation;
  57. this.contents = contents;
  58. this.open = open;
  59. }
  60. public bool compare(string suffix)
  61. {
  62. return this.suffix == suffix;
  63. }
  64. public string toString()
  65. {
  66. return "File name = " + this.FileName + suffix + "Size = " + sizeInMbs +
  67. "Date of creation = " + dateOfCreation + "is open:" + open + "contents = " + contents;
  68. }
  69.  
  70. public string FileName
  71. {
  72. get { return fileName; }
  73. set { fileName = value; }
  74. }
  75.  
  76. public string Suffix // property
  77. {
  78. get { return suffix; } // get method
  79. set { suffix = value; } // set method
  80. }
  81.  
  82. public double SizeInMbs
  83. {
  84. get { return sizeInMbs; }
  85. set { sizeInMbs = value; }
  86. }
  87.  
  88. public DateTime DateOfCreation
  89. {
  90. get { return dateOfCreation; }
  91. set { dateOfCreation = value; }
  92. }
  93.  
  94. public string Contents
  95. {
  96. get { return contents; }
  97. set { contents = value; }
  98. }
  99.  
  100. public bool Open
  101. {
  102. get { return open; }
  103. set { open = value; }
  104. }
  105.  
  106. }
  107. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement