I am having trouble inheriting constructors in my project. I am trying to assign a ValueRadius in the child Orange class that will fit in with my ValueA and Value B in the parent class Shapes_5. I also want to add additional getter and setter method for ValueRadius.
Below is my code so far :
code: (JAVA)
public class Shapes_5
{
public static void main(String[] args)
{
Shapes_Values c = new Shapes_Values() ;
c.setValueA(5);
c.setValueB(14) ;
c.goToPrinter() ;
}
}
class Shapes_Values
{
int ValueA;
int ValueB;
void setValueA(int iValueA) //setter method
{
ValueA = iValueA;
}
void setValueB(int iValueB) //setter method
{
ValueB = iValueB;
}
int getValueA() //getter method
{
return ValueA;
}
int getValueB() //getter method
{
return ValueB;
}
void goToPrinter() //Outputs the coordinates of the shape
{
System.out.prin tln("[" + ValueA + "," + ValueB + "]");
}
}
class Orange extends Shapes_5
{
protected int ValueRadius=2;
public Orange(int iValueA, int iValueB)
{
super(iValueA,i ValueB);
}
class Shapes_Values
{
int ValueRadius;
void setValueRadius( int iValueRadius) //setter method
{
ValueRadius = iValueRadius;
}
int getValueRadius( ) //getter method
{
return ValueRadius;
}
}
}
Below is my code so far :
code: (JAVA)
public class Shapes_5
{
public static void main(String[] args)
{
Shapes_Values c = new Shapes_Values() ;
c.setValueA(5);
c.setValueB(14) ;
c.goToPrinter() ;
}
}
class Shapes_Values
{
int ValueA;
int ValueB;
void setValueA(int iValueA) //setter method
{
ValueA = iValueA;
}
void setValueB(int iValueB) //setter method
{
ValueB = iValueB;
}
int getValueA() //getter method
{
return ValueA;
}
int getValueB() //getter method
{
return ValueB;
}
void goToPrinter() //Outputs the coordinates of the shape
{
System.out.prin tln("[" + ValueA + "," + ValueB + "]");
}
}
class Orange extends Shapes_5
{
protected int ValueRadius=2;
public Orange(int iValueA, int iValueB)
{
super(iValueA,i ValueB);
}
class Shapes_Values
{
int ValueRadius;
void setValueRadius( int iValueRadius) //setter method
{
ValueRadius = iValueRadius;
}
int getValueRadius( ) //getter method
{
return ValueRadius;
}
}
}
Comment