Designing a Method and Test Program

Slides:



Advertisements
Similar presentations
Introduction to Eclipse. Start Eclipse Click and then click Eclipse from the menu: Or open a shell and type eclipse after the prompt.
Advertisements

CSCI 6962: Server-side Design and Programming Input Validation and Error Handling.
Overloading methods review When is the return statement required? What do the following method headers tell us? public static int max (int a, int b)
Slides prepared by Rose Williams, Binghamton University Chapter 11 Recursion.
Computer Programming and Basic Software Engineering 4. Basic Software Engineering 1 Writing a Good Program 4. Basic Software Engineering 3 October 2007.
COMP 110 Introduction to Programming Mr. Joshua Stough October 8, 2007.
1 Gentle Introduction to Programming Tirgul 1: Shell and Scala “hands on” in the lab.
AP Computer Science.  Not necessary but good programming practice in Java  When you override a super class method notation.
1 Gentle Introduction to Programming Tirgul 2: Scala “hands on” in the lab.
1 Project 5: Median. 2 The median of a collection of numbers is the member for which there are an equal number less than or equal and greater than or.
CSCI 6962: Server-side Design and Programming Validation Tools in Java Server Faces.
Programming in Java Unit 2. Class and variable declaration A class is best thought of as a template from which objects are created. You can create many.
Slides prepared by Rose Williams, Binghamton University ICS201 Lecture 19 : Recursion King Fahd University of Petroleum & Minerals College of Computer.
Java development environment and Review of Java. Eclipse TM Intergrated Development Environment (IDE) Running Eclipse: Warning: Never check the “Use this.
1 ENGI 2420 Structured Programming (Lab Tutorial 7) Memorial University of Newfoundland.
Chapter 5 Introduction to Defining Classes
Chapter 3 Introduction to Classes and Objects Definitions Examples.
Compiler Construction By: Muhammad Nadeem Edited By: M. Bilal Qureshi.
C++ Programming: Program Design Including Data Structures, Fourth Edition Chapter 6: User-Defined Functions I.
Classes, Interfaces and Packages
1 ENGI 2420 Structured Programming (Lab Tutorial 7) Memorial University of Newfoundland.
C++ Programming: From Problem Analysis to Program Design, Fourth Edition Chapter 6: User-Defined Functions I.
1 Project 2: Using Variables and Expressions. 222 Project 2 Overview For this project you will work with three programs Circle Paint Ideal_Weight What.
Chapter 5 Defining Classes II Copyright © 2010 Pearson Addison-Wesley. All rights reserved.
Method OverloadingtMyn1 Method overloading Methods of the same name can be declared in the same class, as long as they have different sets of parameters.
 Static  Example for Static Field  Example for Static Method  Math class methods  Casting  Scope of Declaration  Method Overloading  Constructor.
1 Introduction to Object Oriented Programming Chapter 10.
1 Project 5: Leap Years. 222 Leap Years Write a program that reads an integer value from the user representing a year and determines if the year is a.
Linux CSE 1222 CSE1222: Lecture 1BThe Ohio State University1.
Chapter 5 Introduction to Defining Classes Fundamentals of Java.
1 Project 12: Cars from File. This is an extension of Project 11, Car Class You may use the posted solution for Project 11 as a starting point for this.
In this session you will: Implement your code magnet lab – Put your method in standard format – Add alternative magnets to your method – Create and test.
In this session you will: See how various techniques are used to test methods for correct operation See how using testing templates can speed up code magnet.
Basic Concepts: computer, program, programming …
Recursion Version 1.0.
The eclipse IDE IDE = “Integrated Development Environment”
More About Objects and Methods
Topic: Classes and Objects
Chapter 6: User-Defined Functions I
The Class ArrayLinearList
Java Primer 1: Types, Classes and Operators
Microlabs in Computer Science
Chapter 20 Generic Classes and Methods
C Basics.
Programming Language Concepts (CIS 635)
Data Structures Recursion CIS265/506: Chapter 06 - Recursion.
Primitive Types Vs. Reference Types, Strings, Enumerations
Introduction to Strings
Peer Instruction 6 Java Arrays.
How to Run a Java Program
Name: Rubaisha Rajpoot
Java Classes and Objects 3rd Lecture
Week 4 Object-based Programming (2) Classes and Objects: A Deeper Look
Sridhar Narayan Java Basics Sridhar Narayan
The Basics of Recursion
How to Run a Java Program
CS2011 Introduction to Programming I Methods (I)
Recursion Chapter 11.
CSE 501N Fall ‘09 13: Interfaces and Multiple Representation
Chapter 6: User-Defined Functions I
Java Programming Review 1
IDE’s and Debugging.
Recursion Chapter 11.
Introduction to Strings
Running a Java Program using Blue Jay.
Chapter 13 Abstract Classes and Interfaces Part 01
Topic 25 - more array algorithms
Testing & Security Dr. X.
Introduction to Strings
8.3 Vectors Copyright © 2008 Pearson Addison-Wesley. All rights reserved. 1.
Presentation transcript:

Designing a Method and Test Program In this session you will: See how using testing templates can speed up code magnet lab development Write the function you want students to construct and adapt one of the provided templates to suit your needs Implement and test your method outside of WAGS

Available Test Templates Parameter Type(s) Return Type Sample Method integer iterative Fibonacci boolean prime checker integer, integer combinations C(n,r) integer array longest consecutive increasing streak Integer array more positives than negatives Integer, integer array Remove int value from int array string # of digit characters in string is string a palindrome remove all non-alphabetic characters character, string # of characters greater than the character parameter double array double variance double array, double array Pearson correlation coefficient Select your desired signature now for your microlab method.

Step One: Download and Unzip Files The appropriate files can be downloaded from http://cs.appstate.edu/microlabs/ under workshop resources There are four Java files involved <<signature>>Test.java – this is heart of the test program; does not need modification ParamDataAndInvocations.java –This file will be modified as described in the steps outlined below CorrectMethod.java – this file contains a correct version of the method being implemented Student.java – another copy of the correct method; if not in the download then make it yourself

Step Two: Get Demo Program Working Use your favorite IDE (Eclipse, NetBeans, etc.) Create a Java Project Do not use a package (use a default) Load the files <<signature>>Test.java, ParamDataAndInvocations.java, CorrectMethod.java, and Student.java Compile and run the main program: <<signature>>Test.java; NOTE: you will get an error message about a missing argument Verify that everything worked as expected

Step Three: Implement Your Method Modify the sample method in CorrectMethod.java to the method you want students to implement Put a copy of this method in Student.java

Step Four: Set Parameters & Invocations Modify test data and method invocation public class ParamDataAndInvocations { int[] numData = {5, 3, 8, 1, 0}; public int invokeCorrectMethod(CorrectMethod myCorrectMethod,int n){ return myCorrectMethod.iterativeFibonacci(n); } public int invokeStudentMethod(Student student,int n){ return student.iterativeFibonacci(n); This example had a single integer parameter; your template may be different Put the name of the method in the CorrectMethod.java file here. Put the name of the method in the Student.java file here.

Step Five: Run Your Program Make sure your method is compiled and runs correctly Make sure your parameter data includes limiting cases for the method you have designed, such as an empty string if you had a string parameter Modify the method in the Student class to create an error; make sure you test cases detect the error If you are done and the workshop hasn’t proceeded to the next session; repeat the above process for a second method.