Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

3. Implement the class Date that represents a date in day/month/year format as shown in the UML class diagram below with following details: Default constructor

image text in transcribed
3. Implement the class Date that represents a date in day/month/year format as shown in the UML class diagram below with following details: Default constructor should generate a randomdate (random year must be in range 1970-2018). The other constructor set the date accordingtothe given parameters(arguments). Both constructors should validate date entries with the help of the private function validateDate. validateDate checks for non-negative years, months range is 1-12 and day's range is 1-31 and also according to the table below otherwise it will set illegal values only to 1. . . display method should show the date like in the following example: 28-2-2018 . isEqual receives another date and return true if both dates are equal Month Month Name Number of Date day int (no leap years) month: int year: int +Date) Date(d: int, m: int, y. int) +getDay0: int +getMonth int + getyeanx int +isEqual(dat: Date): boolean String(): String Implement another class called Day which contains a Date object and a string attribute that represents the name of the day (eg Saturday, Sunday, ..etc). For example, today is Wednesday where the date is 28/2/2018. The constructor accepts and initializes the day name and its date object. Add the getter methods getDate and getDayName. Don't add any setters Run a main function that will create a two Date objects: one for today 28/2/2018 and the other is random date. Display full information of both days to the screen and state (using the available methods) if both dates are the same. Then, create one Day object representing today "Wednesday" with current date and display its full information (as read from the day object) to the screen as follows. Today is Wednesday and the date is 28-2-2018

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database And Expert Systems Applications 22nd International Conference Dexa 2011 Toulouse France August/September 2011 Proceedings Part 1 Lncs 6860

Authors: Abdelkader Hameurlain ,Stephen W. Liddle ,Klaus-Dieter Schewe ,Xiaofang Zhou

2011th Edition

3642230873, 978-3642230875

More Books

Students also viewed these Databases questions

Question

Describe the four components of emotional intelligence.

Answered: 1 week ago