Classes
A group of problems that cover creating the programming structure called a class. Learn to use a class to organize variables and actions.Make a Class Field
Begin building a simple class by adding a field to the TestClass in the fieldClass.quorum tab. This field will be named message and be assigned a value of "This is a message from the TestClass field, message." In the next few problems you will get a chance to expand on this class.
Make a Setter Action
Now that you have created a field, add the ability to change the value of the message field. Swap the editor to the setClass.quorum tab. Add the action block and edit the action to be named SetMessage with one text parameter. Then, set the field to the parameter value. This problem has no output yet, but it should not have errors when it is run.
Make a Getter Action
Now that you have created a field and a setter action, add the ability to get the value of the message field. Swap the editor to the getClass.quorum tab. Add the action block and edit the action to be named GetMessage that returns text. Then, add and edit the return block so it returns the message field.
Swap back to the Main.quorum tab in the editor. Then read through the code and check that action call works with the GetMessage action you wrote. The program should output the following when the GetMessage action is complete.
This is a message from the TestClass field, message.
Set the message from outside of the TestClass.
Make a Class Action
Continue building a the test class by adding an action to the TestClass in the actionClass.quorum tab. This action will be named Test and output the message "This is a message from the TestClass action, Test."
Calling a Class's Action
In this program, read through the class with a field, getter, setter, and test action located in the testClass.quorum tab. Then add the object and action call blocks to the Main.quorum tab. Make the program output the following text, This is a message from the TestClass action, Test.
Accessing a Class's Field
In this program, create a TestClass object and output the message field in the Main.quorum editor tab. Call the SetMessage and GetMessage actions to output the following text, This is a message from the TestClass field, message.
Build a Grade Class
In this program, create a class called Grade that stores a numerical score and has an action to convert the score to a letter grade. Build this class in the grade.quorum tab in the editor. This class stores an integer score as a field. It must also have a setter and getter action for the score field. The setter action sets the score field and is called SetScore. The getter action gets the score field and is called GetScore. The last action this class needs is the ConvertToLetterGrade action, which returns a letter grade for the value stored in the score field. Build all of this in the grade.quorum tab.
The Main.quorum tab uses the Grade class to set the score and convert it to a letter grade. When you have made the Grade class, this program will output the following.
83 is a letter grade of B