Part 1 Menu Exploration

Part 2 Documentation and Analysis

  • Explain where a Class is defined: You define a class whenever you need to add variables, objects or methods to your code. Here a class called Menu is being defined. It will hold different variables, objects and methods.
    public class Menu {
    
  • Explain where an instances of a Class is defined: An instance of a class is defined when you create an object of that class. Here in Code.org a new object of the Painter class called myPainter is being created
    Painter myPainter = new Painter();
    
  • Explain where an object is Calling a Method: An object calls a method when it wants to preform that action and execute the code. Here the Menu class is calling its main method to execute.
    Menu.main(null);
    
  • Explain where an object is Mutating data: The Integer object is using the method parseInt to mutate the user input, which automatically enters as a string, into an interger. This integer is then stored in a new variable called userNum
    userNum = Integer.parseInt(userInputStr);
    
  • Constructors: methods with the same name as the class it is in. It is a speacial methods used to initialize objects. Here is a constructor that takes parameters inside of a class called ThreeString - Exploration Code
    //constructor that takes parameters
     ThreeString(String str1, String str2, String str3)
     {
        if (validString(str1) && validString(str2) && validString(str3))
        {
           string1 = str1;
           string2 = str2;
           string3 = str3;
        }
        else
        {
           string1 = DEFAULT_STRING;
           string2 = DEFAULT_STRING;
           string3 = DEFAULT_STRING;         
        }
     }
    
  • Mutators: methods that mutate the value of a private member variable. Here the methods setString1 sets the value of a private member of the ThreeString class called string1
    public boolean setString1(String str) 
     {
        boolean status = false;
        if (validString(str))
        {
           string1 = str;
           status = true;
        }
        return status;
     }
    
  • Accessors: methods that accesses and returns the value of a private member variable. Here the getString1 method acesses and returns the value of the private member string1.
     public String getString1()
     {
        return string1;
     }
    
  • Describe Console, GUI differences, or Code.org differences: A console is not as visual as the other two. It requires the user to enter inputs and returns respective outputs. To code, it requires a good understanding of script and syntax. The GUI (graphic user interface) is more user friendly because it has a visual display and it is a more clickable platform. But you can’t really perform multiple tasks at once. On Code.org there is the painter as a visual object to help understand exactly how the code implements. The file and public class name should be the same. This platform is great for beginners to begin to learn how to code.

Part 3 Other

  • Unit 1 completed on Code.org

Ticket Issue #3