Learning the Concepts of Classes and Objects in a Game

13 downloads 175 Views 221KB Size Report
We developed a game-like instructional course module titled ... programming courses are taught and the way students learn ..... online survey of educators.
Learning the Concepts of Classes and Objects in a Game Jinghua Zhang

Elvira R. Caldwell

Mustafa Atay

Elva J. Jones

Department of Computer Science, Winston-Salem State University, Winston-Salem, NC, USA

Abstract— Learning Object-Oriented Programming (OOP) is challenging for students who are new to programming. Many students have difficulty understanding the concepts of classes and objects, which are two main aspects of OOP. We developed a game-like instructional course module titled “Bionic Weasel”. This module was designed to enhance students’ understanding about classes and objects through game playing. This paper presents the design and implementation of the module and reports our experiences and results of using it in the lab. This module was used in CSC1310 Computer Programming I class in the Department of Computer Science (CS) at Winston-Salem State University (WSSU) in Fall 2011. To evaluate the impact of this game-like module, a pre-test, a post-test, and a survey were conducted. The pre-test and post-test comparison indicates that the learning game has significantly enhanced student learning on the OOP topics. Survey results and comments from students were also very positive. Keywords: Game-Based Learnnig, OOP, Classes and Objects, Programming, Computer Science Education

1. Introduction Research shows that the fear of programming is one of the reasons why students do not want to major in CS. The traditional method of teaching Computer Programming focuses too much on the syntax of a programming language, which can be extremely difficult for students who are completely new to programming. Many innovative educational approaches have been proposed to motivate and engage students while achieving the desired student learning outcomes [1-4]. The survey conducted in [5] lists the most difficult topics in CS1. Sung et al. implemented some gamebased lab assignments to enhance student learning on difficult programming topics like arrays [6-7]. Research show that learning difficult programming concepts in the gaming context will create high levels of enthusiasm and excitement about programming which will ultimately help students do better [8-9]. For example, UNC Charlotte Game2Learn project has been very successful in leveraging games in improving introductory computing courses [8-10]. Using games has become a very promising and effective approach to energize computing curriculum and engage students in the computing field. Some institutions

incorporate gaming through computing curriculum [11] and some institutions create computer science game degree programs [12] Our students like many others struggle with programming. When programming assignments are distributed, the frustrated cries often heard such as “Can you help me understand this? This problem is too hard to code. Please help me. How am I supposed to do this?” Visual learners struggle with the abstract concept of programming. Computer programming is seen by a vast majority of students as more difficult and time consuming, as well as less interesting than other courses of study. Learning to program is a time consuming task, as a very large number of hours must be spent at computer writing and debugging code (even if the student is already familiar with programming languages which, for the majority of our students, is not the case). Concepts such as structuring code, reusability, ease of maintenance, meaningful naming and user interface design need to be considered for all but the most basic programs. Unfortunately, this gives students a sense of information overload as well as a seemingly unstructured set of concepts to link together. The complexity of OOP adds a number of difficulties in addition to the problems of any first programming courses such as variables, identifiers, methods, and classes, and objects. Most freshmen entering the computer science major have no previous programming experience and some have only limited experience working with computers. Most introductory programming courses have a very high attrition rate. Introductory programming classes typically lose more than 50% of the students that enroll by the end of the course. The test results of students in Computer Programming courses and the faculty observation urge us to try and implement an effective approach to transform the way the programming courses are taught and the way students learn at WSSU. Game-based learning has been very successful in the literature. We have not seen any games designed to help students learn the concepts of classes and objects, which our students struggle with most. We decided to develop a gamelike instructional course module to help student have better understanding of this topic and improve their scores on the tests. In section 2, we describe the Bionic Weasel game in detail.

Section 3 shows the results and reports our experiences using the module in the classroom. Conclusions and future works are described in section 4.

2. Bionic Weasel Game Game development team in the CS department at WSSU consists of faculty, three undergraduate students and one graduate student. The advisory board oversees the implementation of the game-like instructional modules. The advisory board consists of faculty from department of computer science and department of education and professionals from game industry. The goal for this game is to enhance student learning of the concepts of classes and objects. After brainstorming the game ideas and producing the storyboard, the team decided to use the GameMaker 8.1 to implement the game and decided to the name the game as “Bionic Weasel”. It took the team about three months to fully develop the game. The core gameplay mechanism for this game is to let the player create objects using different classes to help the weasel avoid dangers with the goal of helping it exit the chamber safely. The player controls the bionic weasel created by the scientist. The scientist guides the player through each level of the gameplay by providing a tutorial or an example for each task. The main menu of the game provides three options: Start Game, How to Play and Exit Game. Once the player selects the Start Game option, the player can choose to start a new game or load a previously saved game. The “save game” and “load game” features allow the player to save the game and continue to play at a later time. At the beginning of the game play, the player is asked to enter the banner ID number as shown in Fig. 1, which is a nine digit unique number at school. This number is used to generate a unique confirmation code at the end of the game to prove that the player has finished the game. This feature gives instructors an option to use the game as homework or an extra credit assignment outside the classroom. After the player cleared each level, the score summary will be displayed as shown in Fig. 2. The scoring is based on the number of objects the player has created and correctness of the statements. The player begins the game with three lives. The game consists of four levels and each level is designed to achieve specific learning goals.

2.1

Level One

The students are expected to gain the following skills after completing the level one of the game:

Figure 1. Enter a unique number to start the game.

Figure 2. Level Summary

1. 2. 3.

Be able to create objects using different classes; Be able to use constructors that accept one argument; Be able to use the methods defined in the class;

In order to pass this level, the player needs to create objects to protect the weasel from falling spikes. The scientist provides step-by-step guidance and the player is expected to follow the guidance and learn from the scientist. There are two predefined classes: Pipe and Cube. The player needs to write a correct statement to create a Pipe or a Cube to protect the weasel. The player is presented a coding panel shown in Fig.3 to enter the statements. The statements must follow the syntax rules. A parser has been implemented to compile the statements. Immediate feedback will be provided to show the syntax errors. If there are no compile errors and the “RUN” button is clicked, the statements will be executed. For instance, in order to create a Cube object and make it float, the player needs to enter the statements, which are highlighted in gray as shown in Fig. 4. The Cube object is created as shown in Fig. 5 if the statements are correct. If the player enters a wrong statement as shown in Fig. 6 by calling a no-arg constructor, the game will provide an immediate feedback as shown in Fig. 7.

 

Figure 7. Error Message

2.2

Figure 3. Coding Panel

 

Level Two

The learning goal of this level for students is to gain proficiency of the concepts learned in level one. The difficulty of the gameplay increases by adding hot lava. The player has to create a Cube object to cover that in order to move on. This level also provides a checkpoint as shown in Fig. 9, which allows the player restarts at this point if the player loses all the lives instead of restarting from level one. The player can use the methods defined in the class to manipulate the objects such as rotating a pipe by calling Rotate() method in Pipe class as shown in Fig. 8. As a result, the pipe will be rotated as shown in Fig. 9.

Figure 8. Calling Rotate() method in Pipe class.

Figure 4. Statements to create a cube object and make it float

Figure 9. Rotated pipe

2.3

Figure 5. A Cube object is created.

 

Level Three

The students are expected to gain the following skills after completing the level three of the game: 1. 2.

Figure 6. Wrong Statement to create a Cube

 

Understand the parameter passing rules; Be able to use constructors that accept multiple arguments;

In level three, the player has to use the constructor with multiple parameters to create objects. The constructor with a single parameter is disabled in this level. The syntax of calling constructors with multiple parameters is a common source of error. The player will learn to provide arguments,

which must be given in the same order as their respective parameters in the constructor. For example, the player needs to create a red Cube object at the right side of the weasel. The correct statements are shown in Fig. 10 and the result is shown in Fig.11.

multiple parameters and using the methods defined in class. In the post-test, students need to be able to modify the existing constructor by adding an additional parameter and add an additional constructor. The post-test and pre-test results comparison of all participants is shown in Table 2. The class average increased from 45.44 to 71.28. Table 3 shows the comparison results by gender. We found that 78% of participants showed improvements on the post-test and 60% of female participants got better grades on the posttest.

Figure 10. Using the constructor with multiple parameters.

Figure 11. A red Cube object is created. 

2.4

Level Four

The learning goal of this level for students is to gain proficiency on the concepts presented in the previous three levels. The gameplay becomes more challenging in this level by adding additional spikes moving from left to right, which requires the player enter the correct statements faster.

3. Classroom Experience 3.1

Evaluation Results

This game-like instructional module was used in CSC1310 Computer Programming class at WSSU in Fall 2011. Eighteen students participated in this study during the lab session. 94% participants were African American students and 6% were Hispanic. The participants included five (28%) females and thirteen (72%) males. Most participants are traditional students, sixteen CS/IT majors, and two Math majors. We do not have a controlled group in this study. All the participants had the lecture on the concepts of classes and objects in class by the same instructor before they came to the lab session. They took the pre-test, played the game and then took the post-test and the survey in one lab session (1 hour 45 minutes). Some students finished it early and some students used the entire session to finish the tasks. Pre-test and post-test were similar as shown in Table 1. The questions were listed in blue. In both tests, students were expected to know the output of a given code segment which creates objects and uses methods defined in class. In the pretest, students were tested on adding a constructor with two arguments, creating objects using the constructor with

The survey questionnaire included seven questions regarding the features of the game. The choices on the questionnaire were Strongly Agree, Agree, Disagree, and Strongly Disagree. The Table 4 shows the percentage of students who marked Strongly Agree/Agree for each question. It is worthy to note that 100% of participants agree that the game helped them to understand the concepts of classes and objects. We are glad to find out that about 90% of students enjoyed playing the game. Participants also reported some bugs in the game and provided many useful comments in terms of how to improve this module.

3.2

Lessons Learned

Several lessons have been learned in this process. The gamers finished the module really fast and non-gamers had hard time manipulating the controls. The game interface needs to be simplified so that it will not become the barrier for non-gamers. The playtime should be no longer than twenty minutes. We also noticed that students who skipped the tutorial step showed poor results. The game should have allowed students to repeat the tutorials if students skipped them or didn’t fully understand them.

4. Conclusions and Future Work Since “Bionic Weasel” is the first game-like instructional module we have developed, we are very encouraged by the results. The comparison of pre-test and post-test results suggested that this module had a significant impact on student learning. This game module will be refined based on the feedback from the students, faculty and the advisory board. We plan to add more OOP features and concepts in the future. The refined module will be used as a learning activity in the Computer Programming courses in the upcoming semesters. It allows us to continuously assess the impact of this game-like instructional module on learning. It will be made available on our project website for instructors and students at other institutions.

5. Acknowledgements This work was supported by NSF-HRD-1137548 grant and by WSSU RIP grant. Many thanks go to Amos M. Baker, Emanuel Smith and Matthew Perkins for their contributions to this project.

Table 1. Pre-Test vs. Post-Test Pre-Test /* The Pet class stores data for a pet. */ public class Pet{ private String name; // A pet's name private String type; // A pet's type private int age; // A pet's age public void setName(String n){ name = n; } public void setType(String t){ type = t; } public String getName(){ return name; } public String getType(){ return type; } } Q1. What is the output after the following code is executed? Use Scooby for the pet’s name and dog for the pet type. public class PetDemo{ public static void main(String[] args){ // Create a Scanner object for keyboard input. Scanner keyboard = new Scanner(System.in); // Create a Pet object. Pet myPet = new Pet(); // Get the pet's name. System.out.print("Enter the name of your pet: "); myPet.setName(keyboard.nextLine()); // Get the pet's type. System.out.print("Enter the type of your pet: "); myPet.setType(keyboard.nextLine()); // Get the pet's age. System.out.print("Enter the age of your pet: "); myPet.setAge(keyboard.nextInt()); // Display pet's information. System.out.println(); System.out.println("Here is the information you provided:"); System.out.println("Pet Name:"+ myPet.getName()); System.out.println("Pet Type:"+ myPet.getType()); } } Q2. Add a constructor that accepts the pet’s name, type as arguments. Q3. Fill in the blanks so that the constructor from Q2 is executed. public class PetDemo{ public static void main(String[] args){ // Create a Scanner object for keyboard input. Scanner keyboard = new Scanner(System.in); // Create a Pet object. 1. ___________________________________________ System.out.println(); // Display pet's name 2. ___________________________________________ // Display pet’s type 3.____________________________________________ } }

Post-Test /*Circle class */ public class Circle {  private final double PI = 3.14159; // Constant for pi private double radius; // The circle's radius public Circle(double r){ radius = r; } public void setRadius(double r){ radius = r; } public double getRadius(){ return radius; } public double getArea(){ return PI * radius * radius; } public double getDiameter(){ return radius * 2; } public double getCircumference(){ return 2 * PI * radius; } } Q1: Given the following demo program what would be the output? import java.util.Scanner; // Needed for the Scanner class public class CircleDemo{ public static void main(String[] args){ double radius;              

         // Create a Scanner object for keyboard input.          Scanner keyboard = new Scanner(System.in);       Circle c = new Circle(2.0); // Create a Circle object.                // Display geometric info about the circle.  System.out.println("The circle's area is"+c.getArea());    }  }  Q2: Given the following demo program what is the output? The user enters 3 from the keyboard. import java.util.Scanner; // Needed for the Scanner class  public class CircleDemo{ public static void main(String[] args){ double radius;                    // Create a Scanner object for keyboard input. Scanner keyboard = new Scanner(System.in);   // Create a Circle object. Circle c = new Circle(0);         // Get the radius of a circle.           System.out.print("Enter the radius of a circle: "); radius = keyboard.nextDouble(); c.setRadius(radius);                       // Display geometric info about the circle.           System.out.println("The circle's diameter is "+ c.getDiameter());     }  }  Q3. Declare an instance of the Circle class called ball. Q4. How would you change the constructor to include an argument called color along with the radius? Q5. How could you initialize color to blue without including it as an argument with radius in the constructor? Write the new constructor.  

 

Table 2. Post-Test vs. Pre-Test Results Comparison Pre-Test Post-Test

Std.

Mean

45.44

71.28

N

18

18

22.77

25.27

Deviation

Table 3. Post-Test vs. Pre-Test Results Comparison by Gender Gender Pre-Test Post-Test Mean

38

77.6

N

5

5

Std. Deviation

30.33

12.99

Mean

48.31

68.84

Female

N

13

13

Std. Deviation

19.90

28.74

Male

Table 4. Survey Results Features of the Game

Strongly Agree/Agree

1. The directions for the game are clear and easy to follow.

95%

2. The game is enjoyable to play.

89%

3. The game moves to the next level based on my correct responses.

89%

4. The game helped me to understand about classes and objects.

100%

5. The game functions well and is free from bugs (errors).

33%

6. It required a lot of effort for me to concentrate on classes and objects while playing the game.

45%

7. It was easy for me to navigate the game.

83%

6. References [1] S. Yang, T. Breedlove, R. Carestia, Teaching introductory classes using LEGO robotics, Journal of Computing Sciences in Colleges, Vol. 19, Issue 2, pg 113-114, 2003. [2] J. D. Bayliss and S. Strout, Games as a “Flavor” of CS1, Proceedings of the 37th ACM technical symposium on Computer science education (SIGCSE'06), Houston, Texas, USA, 2006.

[3] J. D. Bayliss, Using games in introductory courses: tips from the trenches, Proceedings of the 40th ACM technical symposium on Computer science education (SIGCSE’09), March 04-07, 2009, Chattanooga, TN, USA [4] S. Leutenegger, J. Edgington, A Games First Approach to Teaching Introductory Programming. In Proceedings of the 38th SIGCSE Technical Symposium on Computer Science Education (SIGCSE’ 07),Covington, Kentucky, March, 2007. [5] Dale, N. B. Most difficult topics in CS1: results of an online survey of educators. SIGCSE Bull. 38, 2 (2006), 49-53. [6] K. Sung, M. Panitz, R. Rosenberg, R. Anderson, Assessing Game-Themed Programming Assignments for CS1/2 Courses, Proceedings of the Third International Conference on Game Development in Computer Science Education (GDCSE’08), Feb 2008. [7] K. Sung, M. Panitz, R. Rosenberg, R. Anderson, CS1/2 Game-Themed Programming Assignments for Faculty, Journal of Game Development, Vol. 3, Issue 2, March 2008, PP. 27-47 [8] EAGLE M., BARNES T. Evaluation of a game-based lab assignment. Proceedings of FDG 2009 - Fourth International Conference on the Foundations of Digital Games, 26-30 April, Port Canaveral, FL, pp. 64-70. [9] Michael Eagle, Tiffany Barnes, Experimental evaluation of an educational game for improved learning in introductory computing, Proceedings of the 40th ACM technical symposium on Computer science education, March 04-07, 2009, Chattanooga, TN, USA. [10] Michael Eagle, Tiffany Barnes, Wu's castle: teaching arrays and loops in a game, Proceedings of the 13th annual conference on Innovation and technology in computer science education, June 30-July 02, 2008, Madrid, Spain. [11] B. B. Morrison, J. A. Preston, Engagement: gaming throughout the curriculum, Proceedings of the 40th ACM technical symposium on Computer science education (SIGCSE’09), Chattanooga, TN, USA, March 04-07, 2009. [12] M. Zyda, V. Lacour, C. Swain, Operating a computer science game degree program, Proceedings of the 3rd international conference on Game development in computer science education, p.71-75, February 27-March 03, 2008, Miami, Florida.