Answered You can hire a professional tutor to get the answer.

QUESTION

For my color output i keep getting the java.awt.Color[r=0,g=0,b=0] to display and not the color itself.. I included the screenshot output and code

For my color output i keep getting the java.awt.Color[r=0,g=0,b=0] to display and not the color itself.. I included the screenshot output and code below... any suggestions? ty

/*

 * To change this license header, choose License Headers in Project Properties.

 * To change this template file, choose Tools | Templates

 * and open the template in the editor.

 */

package headphone;

/**

 * File: HeadPhone.java

 *

 * @author: Andrew Chilcoat Date: 30 March, 2018 Purpose: CMIS 141 Homework 3

 */

import java.awt.Color;

public class HeadPhone {

  //Define the constant volume level

  public static final int LOW = 1;

  public static final int MEDIUM = 2;

  public static final int HIGH = 3;

  //Class variables

  private int volume;

  private boolean pluggedIn = true;

  private boolean pluggedOut = false;

  private String manufacturer;

  private Color headPhoneColor;

  String aboutHeadPhones;

  //Default constructor

  public HeadPhone() {

    //setting default values for private member var.

    changeVolume(MEDIUM);

    setPluggedIn(pluggedIn);

    setPluggedOut(pluggedOut);

    setManufacturer("SAMSUNG");

    setColor(Color.green);

  }

//Gettr methods

  public int getVolume() {

    return volume;

  }

  public boolean isPluggedIn() {

    return pluggedIn;

  }

  public boolean isPluggedOut() {

    return pluggedOut;

  }

  public String getManufacturer() {

    return manufacturer;

  }

  public Color getColor() {

    return headPhoneColor;

  }

// Setter methods

  public void changeVolume(int newVolume) {

    //if volume is valid then do not alter

    if (newVolume >= LOW && newVolume <= HIGH) {

      volume = newVolume;

    }

  }

  public void setPluggedIn(boolean isPlugged) {

  pluggedIn = isPlugged;

  }

  public void setPluggedOut(boolean isUnplugged) {

    pluggedOut = isUnplugged;

  }

  public void setManufacturer(String newManufacturer) {

    manufacturer = newManufacturer;

  }

  public void setColor(Color newColor) {

    headPhoneColor = newColor;

  }

/*Methadys

/Create return string to store the headphone status

/add manufacturer/color/on&off/volume info

/return string

*/

  public String toString() {

    String aboutHeadPhones = "";

    aboutHeadPhones = "Manufacturer: " + getManufacturer();

    aboutHeadPhones = aboutHeadPhones + " Color: " + getColor().toString();

    if (isPluggedIn()) {

      aboutHeadPhones = aboutHeadPhones + ", Plugged In";

    } else {

      aboutHeadPhones = aboutHeadPhones + ", Plugged Out";

    }

    if (getVolume() == LOW) {

      aboutHeadPhones = aboutHeadPhones + ", Volume set to LOW";

    } else if (getVolume() == MEDIUM) {

      aboutHeadPhones = aboutHeadPhones + ", Volume set to MEDIUM";

    } else {

      aboutHeadPhones = aboutHeadPhones + ", Volume set to HIGH";

    }

    return aboutHeadPhones;

  }

}

Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question