Untitled

 avatar
unknown
plain_text
2 months ago
4.3 kB
8
Indexable
package Ficha3;

import java.util.ArrayList;
import java.util.Arrays;

public class Musica {

    private String nome;
    private String interpreter;
    private String autor;
    private String editorName;
    private String[] lyrics;
    private String[] symbols;
    private int duration;
    private int streams;

    public Musica(){
        nome = "";
        interpreter = "";
        autor = "";
        editorName = "";
        lyrics = new String[0];
        symbols = new String[0];
        duration = 0;
        streams = 0;
    }

    public Musica(String nome, String interpreter, String autor, String editorName, String lyrics, String[] symbols, int duration, int streams){
        this.nome = nome;
        this.interpreter = interpreter;
        this.autor = autor;
        this.editorName = editorName;
        this.duration =  duration;
        this.streams = streams;
        this.lyrics = new String[lyrics.length()];
        this.symbols = new String[symbols.length];
    }

    public Musica(Musica m) {
        this.nome = m.getNome();
        this.interpreter = m.getInterpreter();
        this.autor = m.getAutor();
        this.editorName = m.getEditorName();
        this.lyrics = m.getLyrics();
        this.symbols = m.getSymbols();
        this.duration = m.getDuration();
        this.streams = m.getStreams();
    }

    public  boolean equals(Object c) {
        if (this == c) {
            return true;
        }
        if (c == null) {
            return false;
        }
        if (this.getClass() != c.getClass()) {
            return false;
        }

        Musica music = (Musica) c;

        return (this.nome.equals(music.getNome())&&this.interpreter.equals(music.getInterpreter())&& this.autor.equals(music.getAutor()));
    }

    public Musica clone(){
        return new Musica(this);
    }

    public String toString(){
        return "Nome " + this.nome + "De " + this.autor +"\n";
    }

    public int getStreams() {
        return streams;
    }

    public void setStreams(int streams) {
        this.streams = streams;
    }

    public int getDuration() {
        return duration;
    }

    public void setDuration(int duration) {
        this.duration = duration;
    }

    public String[] getSymbols() {
        return Arrays.copyOf(this.symbols,this.symbols.length);
    }

    public void setSymbols(String symbols) {
        this.symbols = Arrays.copyOf(this.symbols,this.symbols.length);
    }

    public String[] getLyrics(){
        return Arrays.copyOf(this.lyrics,this.lyrics.length);
    }

    public void setLyrics(String[] lyrics) {

        this.lyrics = Arrays.copyOf(lyrics,lyrics.length);
    }

    public String getEditorName() {
        return editorName;
    }

    public void setEditorName(String editorName) {
        this.editorName = editorName;
    }

    public String getAutor() {
        return autor;
    }

    public void setAutor(String autor) {
        this.autor = autor;
    }

    public String getInterpreter() {
        return interpreter;
    }

    public void setInterpreter(String interpreter) {
        this.interpreter = interpreter;
    }

    public String getNome() {
        return nome;
    }

    public void setNome(String nome) {
        this.nome = nome;
    }

    public int qtsLinhasPoema(){
        int i=0;
        for(i = 0; i < this.lyrics.length&&this.lyrics[i] !=(null); i++){}

        return i;
    }

    public int numeroCarateres(){
        int contador = 0;
        int i;
        for(i = 0; i < this.lyrics.length&&this.lyrics[i] !=(null); i++){
            contador += this.lyrics[i].length();
        }

        return contador;
    }

    public String addLetra(int posicao, String novaLinha){

        if(posicao < 0  || posicao > this.lyrics.length ){
            return "Position Invalid";
        }

        if(this.lyrics.length == this.qtsLinhasPoema() ){

            this.lyrics = Arrays.copyOf(this.lyrics,this.lyrics.length+1);

        }

        System.arraycopy(this.lyrics,posicao,this.lyrics,posicao+1,this.lyrics.length-posicao-1);
        this.lyrics[posicao] = novaLinha;
        return "Line added!";

    }

}
Editor is loading...
Leave a Comment