• Artist.java

  • §
    package MusicLandscape.entities;
  • §

    We add three constructors:

    /**
     * This class represents an artist of performing arts, like a band.
     *
     * @author Jonas Altrock (ew20b126@technikum-wien.at)
     * @version 1
     * @since ExerciseSheet01
     */
    public class Artist {
        /**
         * holds the name of the artist initial value should be unchanged
         *
         * @since ExerciseSheet01
         */
        private String name = "unknown";
  • §

    the default constructor,

        /**
         * creates a default artist a default artists name is the String "unknown" (without quotes)
         */
        public Artist() {
        }
  • §

    a constructor with all properties as arguments,

        /**
         * creates n artist with a certain name
         * @param name - the name of this artist
         */
        public Artist(String name) {
            this.name = name;
        }
  • §

    and a copy constructor that duplicates another Artist object.

        /**
         * creates a copy of an artist
         * @param other - the original artist to be copied
         */
        public Artist(Artist other) {
            this(other.name);
        }
    
        /**
         * gets the name of this artist.
         *
         * @return the name
         */
        public String getName() {
            return name;
        }
    
        /**
         * sets the name of this artist.
         * <p>
         * the name of an artist cannot be null or empty. if an invalid argument is passed to the method the state of the object remains unchanged
         *
         * @param name the new name of the artist
         */
        public void setName(String name) {
            if (name == null || name.isBlank()) {
                return;
            }
            this.name = name;
        }
    }