Ejemplo n.º 1
0
        public string VideoList()
        {
            string template = "";

            for (int i = 0; i < Rentals.Count; i++)
            {
                IRentable rental = Rentals[i];
                if (rental is Video)
                {
                    Video video = (Video)rental;
                    template += $"{i + 1}. {video.Title} - {video.Rating}";
                    //NOTE check if video is an instance of VHS
                }
                if (rental is VHS)
                {
                    //NOTE convert the video to a vhs and save as a variable
                    VHS vidoVHS = (VHS)rental;
                    template += " (VHS), rewound: ";
                }

                //NOTE try to convert to DVD
                DVD videoDVD = rental as DVD;
                //NOTE check for success
                if (videoDVD != null)
                {
                    template += " (DVD), extras: " + videoDVD.Extras;
                }

                template += "\n";
            }

            return(template);
        }
Ejemplo n.º 2
0
        //NOTE METHOD OVERLOADING
        public void Exchange(string choice, bool credit)
        {
            Movie selected = ValidateChoice(choice, RentedMovies);

            if (selected == null)
            {
                System.Console.WriteLine("Invalid Selection");
                return;
            }
            //NOTE TYPE CHECKING
            if (selected is VHS)
            {
                //NOTE Explicit Casting to another class
                VHS selectedVHS = (VHS)selected;
                if (!selectedVHS.isRewound)
                {
                    System.Console.WriteLine("CHARGE THIS MAN ALL THE FINES!!!");
                    selectedVHS.Rewind();
                }
            }
            AvailableMovies.Add(selected);
            RentedMovies.Remove(selected);
        }