// Class Declaration
public class Fruit
{
str name;
str color;
}
// New Method which act as a constructor
public void new(str _name, str _color)
{
name = _name;
color = _color;
}
// Get Color methos inside class Fruit
public str get_color()
{
return color;
}
// Get Name methos inside class Fruit
public str get_name()
{
return name;
}
</xmp>
</pre>
<h4> Code: Job </h4>
<p> This job will access the class </p>
<pre class="prettyprint">
<xmp>
static void AccessClassFruit(Args _args)
{
Fruit apple;
apple = new Fruit("apple","red");
info(strFmt("%1", apple.get_name()));
}
apple
First understand the algorithm carefully. Then study the program line-by-line and compare it with the output. Finally, review the explanation section to strengthen your logic and programming understanding.
Rewrite the program without looking at the code. Modify values, conditions or logic and run it again. This helps improve confidence and strengthens coding skills much faster.
Sign in to save your progress and continue exactly where you left off.