From 82d300b0d15268c64599cfcf83a1747d7ed6bab6 Mon Sep 17 00:00:00 2001 From: Abhishek01039 Date: Tue, 3 Aug 2021 17:39:21 +0530 Subject: [PATCH] enable some best practices --- refactoring-movie/movie.dart | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/refactoring-movie/movie.dart b/refactoring-movie/movie.dart index 67c8c17..e3a4851 100644 --- a/refactoring-movie/movie.dart +++ b/refactoring-movie/movie.dart @@ -1,9 +1,9 @@ class Customer { - String name; - List rentals = List(); - Customer(this.name); + String name; + List rentals = []; + void addRental(Rental rental) { rentals.add(rental); } @@ -26,10 +26,10 @@ class Customer { } class Rental { - Movie movie; - int daysRented; + const Rental(this.movie, this.daysRented); - Rental(this.movie, this.daysRented); + final Movie movie; + final int daysRented; double price() => movie.price(daysRented); @@ -39,18 +39,18 @@ class Rental { } abstract class Movie { - final String title; + const Movie(this.title); - Movie(this.title); + final String title; double price(int days); int frequentRenterPoints(int days); } class NewReleaseMovie implements Movie { - final String title; + const NewReleaseMovie(this.title); - NewReleaseMovie(this.title); + final String title; @override double price(int days) => days * 3.0; @@ -60,9 +60,9 @@ class NewReleaseMovie implements Movie { } class RegularMovie implements Movie { - final String title; + const RegularMovie(this.title); - RegularMovie(this.title); + final String title; @override double price(int days) => days > 2 ? (days - 2) * 1.5 : 2.0; @@ -72,9 +72,9 @@ class RegularMovie implements Movie { } class ChildrenMovie implements Movie { - final String title; + const ChildrenMovie(this.title); - ChildrenMovie(this.title); + final String title; @override double price(int days) {