//These are my codes. They are exactly similar to the above ones. Unless you missed some small
sytax. They run perfectly fine. Which environment are you using to compile and run these
programs?
ColorPencil.java
public class ColorPencil {
private String color;
private double length;
private double thickness;
public ColorPencil(String cpColor,double cpLength,double cpThickness)
{
color = cpColor;
length = cpLength;
thickness = cpThickness;
}
public ColorPencil()
{
color = \"Black\";
length = 6.0;
thickness = 1.5;
}
public void setColor(String cpColor)
{
color = cpColor;
}
public void setLength(double cpLength)
{
length = cpLength;
}
public void setThickness(double cpThickness)
{
thickness = cpThickness;
}
public String getColor()
{
return color;
}
public double getLength()
{
return length;
}
public double getThickness()
{
return thickness;
}
public String newColor(String cpColor)
{
color = cpColor;
return color;
}
public double newLength(double cpLength)
{
length = cpLength;
return length;
}
public double newThickness(double cpThickness)
{
thickness = cpThickness;
return thickness;
}
public static void main(String[] args) {
// TODO Auto-generated method stub
}
}
ColorPencilTest.java
public class ColorPencilTest {
public static void main(String[] args) {
// TODO Auto-generated method stub
ColorPencil change = new ColorPencil();
String origColor = change.getColor();
double origLength = change.getLength();
double origThickness = change.getThickness();
System.out.println(\"Original color of the pencil is \"+origColor+\"\ Original length of the
pencil is \"+origLength+\"\ Original thickness of the pencil is \"+origThickness);
String color1 = \"Pink\";
change.setColor(color1);
System.out.println(\"Color of the pencil is now \"+color1);
double length1 = 5.5;
change.setLength(length1);
System.out.println(\"Length of the pencil is now \"+length1);
double thickness1 = 0.7;
change.setThickness(thickness1);
System.out.println(\"Thickness of the pencil is now \"+thickness1);
}
}
Solution
//These are my codes. They are exactly similar to the above ones. Unless you missed some small
sytax. They run perfectly fine. Which environment are you using to compile and run these
programs?
ColorPencil.java
public class ColorPencil {
private String color;
private double length;
private double thickness;
public ColorPencil(String cpColor,double cpLength,double cpThickness)
{
color = cpColor;
length = cpLength;
thickness = cpThickness;
}
public ColorPencil()
{
color = \"Black\";
length = 6.0;
thickness = 1.5;
}
public void setColor(String cpColor)
{
color = cpColor;
}
public void setLength(double cpLength)
{
length = cpLength;
}
public void setThickness(double cpThickness)
{
thickness = cpThickness;
}
public String getColor()
{
return color;
}
public double getLength()
{
return length;
}
public double getThickness()
{
return thickness;
}
public String newColor(String cpColor)
{
color = cpColor;
return color;
}
public double newLength(double cpLength)
{
length = cpLength;
.
Including Mental Health Support in Project Delivery, 14 May.pdf
These are my codes. They are exactly similar to the above ones. Un.pdf
1. //These are my codes. They are exactly similar to the above ones. Unless you missed some small
sytax. They run perfectly fine. Which environment are you using to compile and run these
programs?
ColorPencil.java
public class ColorPencil {
private String color;
private double length;
private double thickness;
public ColorPencil(String cpColor,double cpLength,double cpThickness)
{
color = cpColor;
length = cpLength;
thickness = cpThickness;
}
public ColorPencil()
{
color = "Black";
length = 6.0;
thickness = 1.5;
}
public void setColor(String cpColor)
{
color = cpColor;
}
public void setLength(double cpLength)
{
length = cpLength;
}
public void setThickness(double cpThickness)
{
2. thickness = cpThickness;
}
public String getColor()
{
return color;
}
public double getLength()
{
return length;
}
public double getThickness()
{
return thickness;
}
public String newColor(String cpColor)
{
color = cpColor;
return color;
}
public double newLength(double cpLength)
{
length = cpLength;
return length;
}
public double newThickness(double cpThickness)
{
thickness = cpThickness;
return thickness;
}
3. public static void main(String[] args) {
// TODO Auto-generated method stub
}
}
ColorPencilTest.java
public class ColorPencilTest {
public static void main(String[] args) {
// TODO Auto-generated method stub
ColorPencil change = new ColorPencil();
String origColor = change.getColor();
double origLength = change.getLength();
double origThickness = change.getThickness();
System.out.println("Original color of the pencil is "+origColor+" Original length of the
pencil is "+origLength+" Original thickness of the pencil is "+origThickness);
String color1 = "Pink";
change.setColor(color1);
System.out.println("Color of the pencil is now "+color1);
double length1 = 5.5;
change.setLength(length1);
System.out.println("Length of the pencil is now "+length1);
double thickness1 = 0.7;
change.setThickness(thickness1);
System.out.println("Thickness of the pencil is now "+thickness1);
}
}
4. Solution
//These are my codes. They are exactly similar to the above ones. Unless you missed some small
sytax. They run perfectly fine. Which environment are you using to compile and run these
programs?
ColorPencil.java
public class ColorPencil {
private String color;
private double length;
private double thickness;
public ColorPencil(String cpColor,double cpLength,double cpThickness)
{
color = cpColor;
length = cpLength;
thickness = cpThickness;
}
public ColorPencil()
{
color = "Black";
length = 6.0;
thickness = 1.5;
}
public void setColor(String cpColor)
{
color = cpColor;
}
public void setLength(double cpLength)
{
length = cpLength;
5. }
public void setThickness(double cpThickness)
{
thickness = cpThickness;
}
public String getColor()
{
return color;
}
public double getLength()
{
return length;
}
public double getThickness()
{
return thickness;
}
public String newColor(String cpColor)
{
color = cpColor;
return color;
}
public double newLength(double cpLength)
{
length = cpLength;
return length;
}
public double newThickness(double cpThickness)
{
6. thickness = cpThickness;
return thickness;
}
public static void main(String[] args) {
// TODO Auto-generated method stub
}
}
ColorPencilTest.java
public class ColorPencilTest {
public static void main(String[] args) {
// TODO Auto-generated method stub
ColorPencil change = new ColorPencil();
String origColor = change.getColor();
double origLength = change.getLength();
double origThickness = change.getThickness();
System.out.println("Original color of the pencil is "+origColor+" Original length of the
pencil is "+origLength+" Original thickness of the pencil is "+origThickness);
String color1 = "Pink";
change.setColor(color1);
System.out.println("Color of the pencil is now "+color1);
double length1 = 5.5;
change.setLength(length1);
System.out.println("Length of the pencil is now "+length1);
double thickness1 = 0.7;