This document provides an overview of the topics covered in a class on basic methods and classes. It includes discussions on Grace Hopper's development of the first computer language COBOL, goals for the class such as demonstrating classes and objects, and important exam information. A pizza project design example demonstrates how classes work together, with one class calculating pizza attributes. The document also covers key concepts like class variables, constructors, methods, the this keyword, and writing tests. It emphasizes modular development and incremental coding with testing. Students are reminded to review materials and labs in preparation for the upcoming Exam 1.
Infinum Android Talks #17 - Testing your Android applications by Ivan KustInfinum
van will show you how to setup unit tests using Robolectric, how to test user interactions using Espresso and provide some tips and tricks for stress-free testing.
This presentation is a part of the COP2272C college level course taught at the Florida Polytechnic University located in Lakeland Florida. The purpose of this course is to introduce students to the C++ language and the fundamentals of object orientated programming..
The course is one semester in length and meets for 2 hours twice a week. The Instructor is Dr. Jim Anderson.
Infinum Android Talks #17 - Testing your Android applications by Ivan KustInfinum
van will show you how to setup unit tests using Robolectric, how to test user interactions using Espresso and provide some tips and tricks for stress-free testing.
This presentation is a part of the COP2272C college level course taught at the Florida Polytechnic University located in Lakeland Florida. The purpose of this course is to introduce students to the C++ language and the fundamentals of object orientated programming..
The course is one semester in length and meets for 2 hours twice a week. The Instructor is Dr. Jim Anderson.
Presentation to Craft CMS Meetup group in Charlotte, NC USA on November 13, 2019. Topic revolves around testing within the Craft framework using Codeception, as well as testing emails with Mailtrap and other types of tests. ~30 min read.
In this lab you will learn how to use the Java Software Development Kit (SDK) with the Eclipse programming tool. In addition, you will create three simple Java programs.
Project3build.xml Builds, tests, and runs the project .docxwoodruffeloisa
Project3/build.xml
Builds, tests, and runs the project Project3.
Project3/manifest.mf
Manifest-Version: 1.0
X-COMMENT: Main-Class will be added automatically by build
Project3/nbproject/build-impl.xml
Must set src.dir
Must set test.src.dir
Must set build.dir
Must set dist.dir
Must set build.classes.dir
Must set dist.javadoc.dir
Must set buil ...
Cmis 102 Effective Communication / snaptutorial.comHarrisGeorg12
CMIS 102 Homework 1 Solution
Introduction to Problem Solving and Algorithm Design
Using the above Code of Ethics, Pick at least 2 of the 8 principles and describe what these principles mean to you. In your write-up, summarize the principles you selected in your own words and provide at least one example of an activity or action you could take that would support each principle and one example of an activity or action that you believe would violate each principle. Be sure your document is well-written with minimal grammatical and spelling issues.
Introduction to Problem Solving and Algorithm Design
Using the above Code of Ethics, Pick at least 2 of the 8 principles and describe what these principles mean to you. In your write-up, summarize the principles you selected in your own words and provide at least one example of an activity or action you could take that would support each principle and one example of an activity or action that you believe would violate each principle. Be sure your document is well-written with minimal grammatical and spelling issues.
Cmis 102 Enthusiastic Study / snaptutorial.comStephenson22
Introduction to Problem Solving and Algorithm Design
Using the above Code of Ethics, Pick at least 2 of the 8 principles and describe what these principles mean to you. In your write-up, summarize the principles you selected in your own words and provide at least one example of an activity or action you could take that would support each principle and one example of an activity or action that you believe would violate each principle. Be sure your document is well-written with minimal grammatical and spelling issues.
Presentation to Craft CMS Meetup group in Charlotte, NC USA on November 13, 2019. Topic revolves around testing within the Craft framework using Codeception, as well as testing emails with Mailtrap and other types of tests. ~30 min read.
In this lab you will learn how to use the Java Software Development Kit (SDK) with the Eclipse programming tool. In addition, you will create three simple Java programs.
Project3build.xml Builds, tests, and runs the project .docxwoodruffeloisa
Project3/build.xml
Builds, tests, and runs the project Project3.
Project3/manifest.mf
Manifest-Version: 1.0
X-COMMENT: Main-Class will be added automatically by build
Project3/nbproject/build-impl.xml
Must set src.dir
Must set test.src.dir
Must set build.dir
Must set dist.dir
Must set build.classes.dir
Must set dist.javadoc.dir
Must set buil ...
Cmis 102 Effective Communication / snaptutorial.comHarrisGeorg12
CMIS 102 Homework 1 Solution
Introduction to Problem Solving and Algorithm Design
Using the above Code of Ethics, Pick at least 2 of the 8 principles and describe what these principles mean to you. In your write-up, summarize the principles you selected in your own words and provide at least one example of an activity or action you could take that would support each principle and one example of an activity or action that you believe would violate each principle. Be sure your document is well-written with minimal grammatical and spelling issues.
Introduction to Problem Solving and Algorithm Design
Using the above Code of Ethics, Pick at least 2 of the 8 principles and describe what these principles mean to you. In your write-up, summarize the principles you selected in your own words and provide at least one example of an activity or action you could take that would support each principle and one example of an activity or action that you believe would violate each principle. Be sure your document is well-written with minimal grammatical and spelling issues.
Cmis 102 Enthusiastic Study / snaptutorial.comStephenson22
Introduction to Problem Solving and Algorithm Design
Using the above Code of Ethics, Pick at least 2 of the 8 principles and describe what these principles mean to you. In your write-up, summarize the principles you selected in your own words and provide at least one example of an activity or action you could take that would support each principle and one example of an activity or action that you believe would violate each principle. Be sure your document is well-written with minimal grammatical and spelling issues.
The Art Pastor's Guide to Sabbath | Steve ThomasonSteve Thomason
What is the purpose of the Sabbath Law in the Torah. It is interesting to compare how the context of the law shifts from Exodus to Deuteronomy. Who gets to rest, and why?
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxEduSkills OECD
Andreas Schleicher presents at the OECD webinar ‘Digital devices in schools: detrimental distraction or secret to success?’ on 27 May 2024. The presentation was based on findings from PISA 2022 results and the webinar helped launch the PISA in Focus ‘Managing screen time: How to protect and equip students against distraction’ https://www.oecd-ilibrary.org/education/managing-screen-time_7c225af4-en and the OECD Education Policy Perspective ‘Students, digital devices and success’ can be found here - https://oe.cd/il/5yV
Ethnobotany and Ethnopharmacology:
Ethnobotany in herbal drug evaluation,
Impact of Ethnobotany in traditional medicine,
New development in herbals,
Bio-prospecting tools for drug discovery,
Role of Ethnopharmacology in drug evaluation,
Reverse Pharmacology.
Synthetic Fiber Construction in lab .pptxPavel ( NSTU)
Synthetic fiber production is a fascinating and complex field that blends chemistry, engineering, and environmental science. By understanding these aspects, students can gain a comprehensive view of synthetic fiber production, its impact on society and the environment, and the potential for future innovations. Synthetic fibers play a crucial role in modern society, impacting various aspects of daily life, industry, and the environment. ynthetic fibers are integral to modern life, offering a range of benefits from cost-effectiveness and versatility to innovative applications and performance characteristics. While they pose environmental challenges, ongoing research and development aim to create more sustainable and eco-friendly alternatives. Understanding the importance of synthetic fibers helps in appreciating their role in the economy, industry, and daily life, while also emphasizing the need for sustainable practices and innovation.
The Roman Empire A Historical Colossus.pdfkaushalkr1407
The Roman Empire, a vast and enduring power, stands as one of history's most remarkable civilizations, leaving an indelible imprint on the world. It emerged from the Roman Republic, transitioning into an imperial powerhouse under the leadership of Augustus Caesar in 27 BCE. This transformation marked the beginning of an era defined by unprecedented territorial expansion, architectural marvels, and profound cultural influence.
The empire's roots lie in the city of Rome, founded, according to legend, by Romulus in 753 BCE. Over centuries, Rome evolved from a small settlement to a formidable republic, characterized by a complex political system with elected officials and checks on power. However, internal strife, class conflicts, and military ambitions paved the way for the end of the Republic. Julius Caesar’s dictatorship and subsequent assassination in 44 BCE created a power vacuum, leading to a civil war. Octavian, later Augustus, emerged victorious, heralding the Roman Empire’s birth.
Under Augustus, the empire experienced the Pax Romana, a 200-year period of relative peace and stability. Augustus reformed the military, established efficient administrative systems, and initiated grand construction projects. The empire's borders expanded, encompassing territories from Britain to Egypt and from Spain to the Euphrates. Roman legions, renowned for their discipline and engineering prowess, secured and maintained these vast territories, building roads, fortifications, and cities that facilitated control and integration.
The Roman Empire’s society was hierarchical, with a rigid class system. At the top were the patricians, wealthy elites who held significant political power. Below them were the plebeians, free citizens with limited political influence, and the vast numbers of slaves who formed the backbone of the economy. The family unit was central, governed by the paterfamilias, the male head who held absolute authority.
Culturally, the Romans were eclectic, absorbing and adapting elements from the civilizations they encountered, particularly the Greeks. Roman art, literature, and philosophy reflected this synthesis, creating a rich cultural tapestry. Latin, the Roman language, became the lingua franca of the Western world, influencing numerous modern languages.
Roman architecture and engineering achievements were monumental. They perfected the arch, vault, and dome, constructing enduring structures like the Colosseum, Pantheon, and aqueducts. These engineering marvels not only showcased Roman ingenuity but also served practical purposes, from public entertainment to water supply.
How to Create Map Views in the Odoo 17 ERPCeline George
The map views are useful for providing a geographical representation of data. They allow users to visualize and analyze the data in a more intuitive manner.
This is a presentation by Dada Robert in a Your Skill Boost masterclass organised by the Excellence Foundation for South Sudan (EFSS) on Saturday, the 25th and Sunday, the 26th of May 2024.
He discussed the concept of quality improvement, emphasizing its applicability to various aspects of life, including personal, project, and program improvements. He defined quality as doing the right thing at the right time in the right way to achieve the best possible results and discussed the concept of the "gap" between what we know and what we do, and how this gap represents the areas we need to improve. He explained the scientific approach to quality improvement, which involves systematic performance analysis, testing and learning, and implementing change ideas. He also highlighted the importance of client focus and a team approach to quality improvement.
Palestine last event orientationfvgnh .pptxRaedMohamed3
An EFL lesson about the current events in Palestine. It is intended to be for intermediate students who wish to increase their listening skills through a short lesson in power point.
2. BYTE FROM COMPUTING HISTORY
Grace Hopper developed the
first computer language,
which eventually became
known as COBOL.
2
3. GOALS FOR TODAY’S CLASS
• Demo in JGRASP
•How classes work together
• Lecture
•More about Classes, Objects, Methods,
& Variables
3
4. IMPORTANT TO NOTE
Exam 1 covers content
from chapters 1 to 3.
You’ll get practice
worksheets and a
sample exam.
4
5. PIZZA PROJECT - DESIGN - T-P-S
1. What does
PizzaCalculator do?
2. What information does
PizzaMain send to /
receive from
PizzaCalculator? 5
6. PIZZA PROJECT DESIGN - T-P-S ANSWERS
1. What does PizzaCalculator do?
It calculates the volume and area of a pizza.
2. What information does PizzaMain send to /
receive from PizzaCalculator?
Sends: arguments for constructor and methods.
Receives: area of pizza.
6
The main class creates new instances of
PizzaCalculator.
The printPizzaVolume methods prints to the
console.
7. SNAPSHOT OF CLASS VARIABLES
7
New
instance
After calling
printPizza
Volume
method
8. SNAPSHOT OF CLASS VARIABLES
8
After calling
calculatePizzaArea methodNew instance
9. DEMO: PIZZA PROJECT
You saw
1. A class user need not know how the class' data and methods are
implemented, but need only understand how each public member
method behaves.
2. A programmer can create one or more objects of the same class
a. declare a reference variable of the class type.
b. assign the variable with an instance of the class type.
3. The new operator explicitly allocates an object of the specified
class type.
4. The "." operator is used to invoke a method on an object.
5. Within a member method, the implicitly-passed object reference
is accessible via the keyword this
9
10. REMINDER: MAIN METHOD
main() is a static method, which
means main() does not have direct
access to the class' instance members.
A programmer must create objects
within main() to call instance methods.
10
11. THE this. keyword
Using this makes clear that a class member is being accessed. Such use is
essential if a field member and parameter have the same identifier because
the parameter name dominates. 11
12. CLICKER QUESTION #1
A Car class (from last week) object is
instantiated:
Car myCar = new Car(13.5, 5.0);
Which one of the following correctly accesses
the fuel amount attribute of myCar?
A. myCar.fuelAmount;
B. myCar.getFuelAmount();
C. myCar.getFuel;
D. myCar.getFuel();
12
13. CLICKER QUESTION #1
A Car class (from last week) object is instantiated:
Car myCar = new Car(13.5, 5.0);
Which one of the following correctly accesses the fuel
amount attribute of myCar?
A. myCar.fuelAmount; private- can’t access
B. myCar.getFuelAmount(); not a method in Car class
C. myCar.getFuel; not a method call
D. myCar.getFuel(); CORRECT
13
14. CLICKER QUESTION #2
Given the method definition below, indicate which is a
valid return statement:
public int calculate(int num1, int num2)
{ ... }
A. return num1, num2;
B. return;
C. return num1 * num2;
D. return (num1, num2);
14
15. CLICKER QUESTION #2 ANSWER
Given the definition below, indicate which is a valid
return statement:
int calculate(int num1, int num2) { ... }
**A return statement can return only one value.
A. return num1, num2;**
B. return; must return int value
C. return num1 * num2; CORRECT
D. return (num1, num2);**
15
16. CLICKER QUESTION #3
16
Choose the incorrect statement
A. Creating methods helps main run faster.
B. Decomposing a program into methods aids
program readability.
C. A method can be defined once, then called
from multiple places in a program.
D. There can be only one main method in a
class.
17. CLICKER QUESTION #3 ANSWER
17
Choose the incorrect statement
A. Creating methods helps main run faster.
B. Decomposing a program into methods aids
program readability. CORRECT
C. A method can be defined once, then called from
multiple places in a program. CORRECT
D. There can be only one main method in a class.
CORRECT
More methods may cause slightly slower
program execution - but improve readability.
18. CLICKER QUESTION #4
Choose the incorrect statement/s
1. Only one constructor can be declared in a class.
2. A constructor must have a return type.
3. A constructor must have at least one parameter.
4. A constructor must be called to make an instance of the
class.
A. 1, 2, 3, 4
B. 1, 2, 3
C. 2, 3, 4
D. 1, 2 18
19. CLICKER QUESTION #4
Choose the incorrect statement/s
1. Only one constructor can be declared in a class. INCORRECT
2. A constructor must have a return type. INCORRECT
3. A constructor must have at least one parameter. INCORRECT
4. A constructor must be called to make an instance of the class.
CORRECT
A. 1, 2, 3, 4
B. 1, 2, 3
C. 2, 3, 4
D. 1, 2
19
20. INTRODUCTION TO STRING CLASS METHODS (1)
Strings are made up of characters. The characters in a
particular string hold fixed positions in that string,
beginning with position 0 and not at 1.
20
String pupName = “Spot”;
char ch = pupName.charAt(1);
// ch is assigned ‘p’
ch = pupName.charAt(0);
// ch is assigned ‘S’
21. STRING CLASS METHODS (2)
Note: Strings are immutable – never change.
pupName is still “Spot”;
Some String methods need arguments.
String pupName = ”Spot";
int len = pupName.length();//len assigned 4
String huh = pupName.concat(“less”); //
Spotless
String bigHuh = pupName.toUpperCase();
//SPOT
21
22. JAVA API - STRING CLASS
https://docs.oracle.com/en/java/javase/12/docs/api/java.base/java/lang/String.html
22
23. CLICKER QUESTION #5
Java's String class has a length() method that
returns the length of the string.
What is returned by the call to the length method below?
String greetingStr = "Hello";
greetingStr.length();
A. 7
B. 5
C. 8
D. 6
23
24. CLICKER QUESTION #5 ANSWER
Java's String class has a length() method that returns
the length of the string.
What is returned by the call to the length method below.
String greetingStr = "Hello";
greetingStr.length();
A. 7
B. 5
C. 8
D. 6
24
25. SUMMARY: PARAMETERS & ARGUMENTS
● Parameter: method input specified in method definition.
○ Upon a call, parameter's memory location is allocated, and
parameter is assigned with argument's value.
○ Upon return, parameter is deleted from memory.
○ Method definition may have multiple parameters, separated by
commas.
○ A method definition with no parameters must still have empty
parentheses()- the call must include parentheses, with no argument.
● Argument: value provided to method's parameter during method call.
○ Parameters are assigned with argument values by position: First
parameter with first argument, second with second, etc.
○
25
26. WEEK 3 TO-DO LIST:
• Check your iClicker grades in Moodle.
• Complete zyBook chapters 1-3 exercises (content for
exam)
• Download Lab 3 code before Friday and check that it
compiles - your group will not wait for you!
• Communicate with us using only Moodle forum or
Piazza.
2
6
28. GOALS FOR TODAY’S CLASS
• Demo of Project 2
• Lecture
• Testing - why and how
• Generating Javadocs
• Demo Javadocs
2
29. WHY AND HOW DO WE TEST?
A chef tastes food before serving.
1. Unit testing means to create and run a testbench
for a specific unit like a method of a class.
2. JUnit testbench tests a program with a series of
input/output checks known as test cases.
a. The testbench creates an object, then checks
public methods for correctness.
3
30. HOW TO WRITE YOUR OWN TESTS
1. Use System.out.print statements in the main class.
Remember to delete when submitting your project! (not a Unit test)
2. Do Unit testing: create and run a testbench for a specific item (or
"unit") like a method or a class. See zyBooks 3.7.
Note: uses if statements, that we have not covered as yet.
4
31. USING JUNIT
Regression testing: retest an item like a class anytime that item is
changed; if previously-passed test cases fail, the item has "regressed".
In the sample test given to you to check if JUnit is installed properly:.
5
32. THE SAMPLE TEST DETAILS
6
Message if
test fails
Expected
value from
test
Method
called for
actual value
In LAB 3, you’ll learn more about running tests
and how the Assert class methods work.
33. DETAILS OF PROJECT 2: Receipt Generator
To be released on Friday
Complete a program where a user can enter item
names and their respective prices, and it will calculate
the cumulative total, and print the list of items they
purchased along with their prices.
Input: a user can enter item names and their
respective prices,
Process: the program calculates the cumulative total
Output: it prints the total, as well as lists the items
purchased along with their prices. 7
34. DETAILS OF PROJECT 2: Receipt Generator
8
Has 2 classes and runs tests.
You need to download and configure JUnit files to run
the tests.
The user
interface
35. DESIGN OF PROJECT 2
Think of main class
as “front-end” and
other class as
“back-end”.
9
36. DEMO - PROJECT 2
Running the starter code
10
Running the tests
37. DEMO - PROJECT 2
Running the finished code
11
Running the tests
38. REVIEW: WHAT YOU SAW IN THE DEMO
1. Configure JUnit path in jGRASP
2. Download and unzip/extract the Project 2 zip file
3. Compile the files.
4. Run the main file.
5. Run the tests.
TO DO for PROJECT 2
1. Complete the tasks - see comments given to you.
2. Run the tests.
3. Upload in Gradescope as zip file.
4. Use the Debugger or ask us for help, if necessary.
12
39. JAVADOC TOOL
13
Documentation generated by Javadoc is known as Application
Programming Interface (API).
We use multi-line comments between the /** and */ characters.
We use tags to explain e.g. @author
47. USING THE MAIN METHOD
21
Creating instances of
ElapsedTime class
Sending arguments to
setTime methodmethod call
48. CLICKER QUESTION #1
Choose the correct statement
A. A private class member cannot be accessed as
this.classMember.
B. The 'this' keyword can be used in a constructor to
invoke a different constructor.
C. Using ‘this’ leads to confusion between class
members and parameter names.
22
49. CLICKER QUESTION #1 ANSWER
Choose the correct statement
A. A private class member cannot be accessed as this.classMember.
It can be accessed from within the same class.
B. The 'this' keyword can be used in a constructor to invoke a different
constructor.
Correct - see the lecture code
C. Using ‘this’ leads to confusion between class members and parameter
names.
Use "this" to distinguish the class member from the parameter name.
23
50. CLICKER QUESTION #2
In main(), given variable declaration:
ElapsedTime startTime = new
ElapsedTime();
Which statement sets startTime to hours
and minutes?
24
A. hours = 5; minutes = 30;
B. setTime.hours = 5;
setTime.minutes = 30;
C. this.setTime(int 5, int 10);
D. None of the above
51. CLICKER QUESTION #2 ANSWER
In main(), given variable declaration:
ElapsedTime startTime = new
ElapsedTime();
Which statement sets startTime to hours
and minutes?
25
A. hours = 5; minutes = 30; not accessible - private.
B. setTime.hours = 5; setTime.minutes = 30;
not accessible - private.
C. this.setTime(int 5, int 10); 'this' is only visible
within a method member, not in main().
D. None of the above
52. WRITING TESTS
• More practice with JUnit testing in LAB 3.
• Start thinking of writing your own tests.
• See figure 3.7.1 in zyBook section 3.7 for how to
write your own tests using a main method.
• Include not just typical values but also border
cases: Unusual or extreme test case values like 0,
negative numbers, or large numbers.
26
53. SUMMARY: HOW TO DEVELOP CODE
• Modular development: Divide a program into separate modules - develop and
test separately and then integrate into a single program.
• Incremental development: Write, compile, and test a small amount of code,
then write, compile, and test a small amount more, and so on.
• Method stub: Create a method definition whose statements have not yet been
written.
• Guidelines:
• Each method should have easily-recognizable behavior, and the behavior of
methods should be easily understandable via the sequence of method calls.
• A method's definition usually shouldn't have more than about 30 lines of
code.
• Regression testing: Retest a class anytime that class is changed.27
54. PREPARE FOR EXAM 1
1. Review from zyBooks chapters 1 to 3
(not the optional content).
2. Review Lecture slides.
3. Review Lab worksheets.
4. Review Project code.
5. Review exam prep worksheet in Moodle
28
55. WEEK 3 TO-DO LIST:
• Check your iClicker grades in Moodle.
• Complete zyBook chapter 1-3 exercises (content for
exam)
• Download and configure JUnit before the lab. There is
a Workshop tonight on JUnit and testing.
• Download Lab 3 code before the lab and check that it
compiles - your group will not wait for you!
• Communicate with us using only Moodle forum or
Piazza.
• Start Project 2 early - seek help in office hours. 2
9