Cont'd from Lesson 2: PPT
7. Clue 4: How to use main method in a class? Examples of classes
Elaboration: (PPT-L2 Slides 24-28), main() method and a Test class
Prompts & Check : Dance with a class now - Kahoot! 1-7
8. Clue 5: How to declare object variables and create objects from a class? Difference between primitive types and object references.
Elaboration: (PPT-L2 Slides 30-36)
Prompts & Check : Create some objects of a class now - Slide #37
9. Clue 6: How to use a constructor? How to access object instance variables and methods?
Elaboration: (PPT-L2 Slides 30-38)
Prompts & Check : Create constructors, use them to create more objects and access instance variables and methods of those objects - Slide #39
10. Clue 7: Instance variables vs static variables, how about methods?
Elaboration: (PPT-L2 Slides 40-43)
Prompts & Check : Kahoot! 9-26
11. Clue 8: Passing objects as parameters of methods - pass by reference.
Elaboration: (PPT-L2 Slides 44-45)
1. Turn ACSL Scrabble into a class with the following design:
1) Add an instance variable to store the initial string. Create a constructor with a string parameter to initialize this instance variable
2) Add an instance method to calculate scores of the string object. The method should take an integer parameter to specify beginning position where the string will be put at.
Create an object in main() by calling the constructor. Run the score method at different starting positions and print out the score.
2. Turn ACSL Map into a class "Trip" and a class "Vehicle" with the following design:
1) )Add "milesPerHour", "averageSpeed" as two instance variables in class Vehicle.
2) Add "startCity", "endCity" and "gasPriceToday" as instance variables in class Trip.
3)Add a constructor of class Trip to initialize all instance variables
4)Add instance methods to return all necessary values to complete the task as required.
3. (Coding Practice): ACSL_DraftPick