must be written in c# (15%) Class Date. (5%) Add a new method int numberofDayssi
ID: 3607052 • Letter: M
Question
must be written in c#
(15%) Class Date.
(5%) Add a new method int numberofDayssince1900 ( ) to class Date that returns the number of days since New Year of 1900 till the date of Date object d = new (day, month, year) that you specify. To be more specific you include the date of d, but not include the date of 1/1/1900. In particular this means numberofDayssince1900 ( ) returns 30 for 1/31/1900, 365 for 1/1/1901, 365 + 365 + 365 + 366 + 31 + 28 = 1520 for 3/1/1905.
(5%) Add 3 new methods isEarlier (Date), isLater(Date), and istheSame (Date) that compares two Dates object and determine which one comes first. Please implement these 3 methods based on the method numberofDayssince1900 ( ) in part (a).
(5%) Test your program with 3 different Dates in 2017, 2010, and 1900, and also two dates of your choice. Show the number of days since 1/1/1900, and which one is earlier, is later etc.
(14%) Enhance class Date to have
(7%) Three methods NextDay, NextMonth, NextYear. Note the NextDay method must handle the case when day is at the end of a month; NextMonth must handle the case when month is December (so next month is January).
(7%) Provide test cases to test NextDay, NextMonth, and NextYear. You need to show the NextDay, NextMonth, and NextYear of 5 different dates: today 10/31/17, 2/28/17, 2/29/16, Christmas eve, and New Year’s eve.
Explanation / Answer
namespace Shadowsocks.Encryption { public class EncryptorInfo { public int KeySize; public int IvSize; public int SaltSize; public int TagSize; public int NonceSize; public int Type; public string InnerLibName; // For those who make use of internal crypto method name // e.g. mbed TLS #region Stream ciphers public EncryptorInfo(string innerLibName, int keySize, int ivSize, int type) { this.KeySize = keySize; this.IvSize = ivSize; this.Type = type; this.InnerLibName = innerLibName; } public EncryptorInfo(int keySize, int ivSize, int type) { this.KeySize = keySize; this.IvSize = ivSize; this.Type = type; this.InnerLibName = string.Empty; } #endregion #region AEAD ciphers public EncryptorInfo(string innerLibName, int keySize, int saltSize, int nonceSize, int tagSize, int type) { this.KeySize = keySize; this.SaltSize = saltSize; this.NonceSize = nonceSize; this.TagSize = tagSize; this.Type = type; this.InnerLibName = innerLibName; } public EncryptorInfo(int keySize, int saltSize, int nonceSize, int tagSize, int type) { this.KeySize = keySize; this.SaltSize = saltSize; this.NonceSize = nonceSize; this.TagSize = tagSize; this.Type = type; this.InnerLibName = string.Empty; } #endregion } public abstract class EncryptorBase : IEncryptor { public const int MAX_INPUT_SIZE = 32768; public const int MAX_DOMAIN_LEN = 255; public const int ADDR_PORT_LEN = 2; public const int ADDR_ATYP_LEN = 1; public const int ATYP_IPv4 = 0x01; public const int ATYP_DOMAIN = 0x03; public const int ATYP_IPv6 = 0x04; public const int MD5_LEN = 16; protected EncryptorBase(string method, string password) { Method = method; Password = password; } protected string Method; protected string Password; public abstract void Encrypt(byte[] buf, int length, byte[] outbuf, out int outlength); public abstract void Decrypt(byte[] buf, int length, byte[] outbuf, out int outlength); public abstract void EncryptUDP(byte[] buf, int length, byte[] outbuf, out int outlength); public abstract void DecryptUDP(byte[] buf, int length, byte[] outbuf, out int outlength); public abstract void Dispose(); public int AddrBufLength { get; set; } = - 1; } }
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.