Skip to content

Instantly share code, notes, and snippets.

@abdullahmansss
Last active June 10, 2022 20:18
Show Gist options
  • Save abdullahmansss/80068f6978b9594aa154a84574bb4ede to your computer and use it in GitHub Desktop.
Save abdullahmansss/80068f6978b9594aa154a84574bb4ede to your computer and use it in GitHub Desktop.
import 'dart:developer';
class Date {
final dynamic year;
final dynamic month;
final dynamic day;
Date({
required this.year,
required this.month,
required this.day,
});
void showDate() {
String year = this.year.toString();
String month = this.month.toString();
String day = this.day.toString();
log('Date: $year-$month-$day');
}
}
class Time {
final dynamic hour;
final dynamic minute;
final dynamic second;
Time({
required this.hour,
required this.minute,
required this.second,
});
void showTime() {
String hour = this.hour.toString();
String minute = this.minute.toString();
String second = this.second.toString();
log('Time: $hour:$minute:$second');
}
}
class DateTime {
final Date date;
final Time time;
DateTime({
required this.date,
required this.time,
});
void toDateTime() {
date.showDate();
time.showTime();
}
}
class DateTimeBuilder {
late DateTime dateTime;
DateTimeBuilder({
required this.dateTime,
});
void prepareDateTime() {
dateTime.toDateTime();
}
}
void main() {
DateTimeBuilder dateTimeBuilder = DateTimeBuilder(
dateTime: DateTime(
date: Date(
year: 2020,
month: 1,
day: 1,
),
time: Time(
hour: '1',
minute: '1',
second: '1',
),
),
);
dateTimeBuilder.prepareDateTime();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment