code to explanationWed, 28 Dec 2022

public class DvdName { private String titleName; public DvdName(String titleName) { this.setTitleName(titleName); } public final void setTitleName(String titleNameIn) { this.titleName = titleNameIn; } public final String getTitleName() { return this.titleName; } public void setNameStarsOn() { this.setTitleName(this.getTitleName().replace(' ','*')); } public void setNameStarsOff() { this.setTitleName(this.getTitleName().replace('*',' ')); } public String toString() { return ("DVD: " + this.getTitleName()); } }

The DvdName class represents a name of a DVD title. A DvdName object is composed of a single String titleName. The DvdName class defines a constructor that takes a String titleNameIn. The DvdName class implements setTitleName to validate the titleNameIn. The DvdName class implements getTitleName which returns the titleName. The DvdName class implements setNameStarsOn which replaces all spaces in titleName with *. The DvdName class implements setNameStarsOff which replaces all * in titleName with spaces. The DvdName class implements toString which returns the DVD name.

Questions about programming?Chat with your personal AI assistant