Exercise
Catalog
Objetive
Create the classes diagram and then, using Visual Studio, a project and the corresponding classes for a catalog utility:
It will be able to store information about music files, films and computer programs.
For each item, it must store: name, code, category and size. For films it must also hold the director, the main actor and the main actress. For music files, the singer and the length (in seconds).
For music and movies it must have a method "Play" (not implemented yet) and also a method "RetrieveInformation", which will (in a later version) connect to an internet server to get information about it.
Use inheritance if needed. In "Main", create arrays of each kind of object.
Example Code
package Catalog;
public class Main
{
public static void main(String[] args)
{
Film[] myFilms = new Film[3];
Music[] myMusic = new Music[3];
ComputerProgram[] myComputerProgram = new ComputerProgram[3];
}
}
public class Item
{
protected String name;
protected String code;
protected String category;
protected String size;
public Item()
{
}
public Item(String name, String code, String category, String size)
{
this.name = name;
this.code = code;
this.category = category;
this.size = size;
}
public final String getName()
{
return name;
}
public final void setName(String value)
{
name = value;
}
public final String getCode()
{
return code;
}
public final void setCode(String value)
{
code = value;
}
public final String getCategory()
{
return category;
}
public final void setCategory(String value)
{
category = value;
}
public final String getSize()
{
return size;
}
public final void setSize(String value)
{
size = value;
}
}
public class Film extends Item
{
protected String director;
protected String mainActor, mainActress;
public Film()
{
}
public Film(String director, String mainActor, String mainActress)
{
this.director = director;
this.mainActor = mainActor;
this.mainActress = mainActress;
}
public final String getDirector()
{
return director;
}
public final void setDirector(String value)
{
director = value;
}
public final String getMainActor()
{
return mainActor;
}
public final void setMainActor(String value)
{
mainActor = value;
}
public final String getMainActress()
{
return mainActress;
}
public final void setMainActress(String value)
{
mainActress = value;
}
public final void Play()
{
}
public final void RetrieveInformation()
{
}
}
public class Music extends Item
{
protected String singer;
protected int length;
public Music()
{
}
public Music(String singer, int length)
{
this.singer = singer;
this.length = length;
}
public final String getSinger()
{
return singer;
}
public final void setSinger(String value)
{
singer = value;
}
public final int getLenght()
{
return length;
}
public final void setLenght(int value)
{
length = value;
}
public final void Play()
{
}
public final void RetrieveInformation()
{
}
}
public class ComputerProgram extends Item
{
}