Lab Exercise Inheritance

 

class Video {

{

private String title; 

private int lenghth;

private final boolean avail;


public Video ( String ttl, int lentgh )

{

    title = ttl; lentgh = 90; avail = true;

}

public void show(String length)

{

    System.out.println(title + ", "+ length + " min. available :" + avail );

    

    }

    

}

public class VideoStore {

    

    public static void main ( String args [])

    {

        Video item1 = new Vieo ("Microcosmos", 90 );

        Movie item2 = new Movie ("Jaws", 120, "Spielberg", "PG" );

        Movie item3 = new Movie ("Ironman", 120, "Avengers", "PG" );

        

        

        item1.show();

        item2.show();

        item3.show();

    }        

}


public class Movie extends Video 

{

        private String   director;

        private String    rating;

        

        public Movide( String ttl, int lngth, String dir, String rtg )

        {

            super( ttl, lngth);

            director = dir; rating = rtng;

        }

        public Movie( String ttl, String dir, String rtng )

        {

            super( ttl );

            director = dir; rating = rtng;

        }        

        public void show()

        {       

            super.show();

          System.out.println(director + "," + rating);

           }

}  

Comments

Popular posts from this blog

Exercise UML