1)When describing my ethnicity, I have a tendency to describe myself as multiethnic. However, I will say where my mom is from most of the times which is Italy and Germany, but with my dad he has all ways referred to himself as a "mutt and proud" and doesn't know his exact origin. My dad has never expressed caring enough to know. We both think that if you are born in America, your parents live in America, and you are surrounded with the culture then you should classify yourself as an American. Simply due to the fact that America thrived on immigration, so in a way we all descended from immigrants in one way or another (if your born in America and have lived your whole life living the culture). Then going to how does my ethnicity compare to that of the people I surround myself with, would also be considered multiethnic. I say this because I have friends who were all born and raised in America, now their grandparents may have directly immigrated to America, and they may consider themselves a different ethnicity, however most of them will admit they either don't know their origin, or they do and it is multiethnic. I feel like being an American we may not have as strict rules on marriage as other countries. For instances on my moms side her mom was Italian, and her father German, and my great-grandparents forbid that they married each other, due to not being the same ethnicity. Anyhow they still ended up coming to America and getting married. Which is very acceptable in American culture.
2) I would describe my ethnicity as an Italian American. My family on my Father's side migrated from Sicily to New York when my Grandma was a kid. I grew up in a very traditional Italian household. The woman of the house which was my Grandmother was the homemaker which included taking care of her two children, cooking, and cleaning. My Grandpa was a man of few words, but a hard worker and military veteran. The house was always loud with people in and out. Family get-togethers were large and always included a lot of Italian food and a lot of cursing. My Mother, on the other hand, is only a small percentage of Italian. My mother and my children are who I spend most of my time with now. My children's father is German American. Our family blends together just fine, however, I am typically the loudest and most outspoken.
3)When describing my ethnicity, I have a tendency to describe myself as multiethnic. However, I will say where my mom is from most of the times which is Italy and Germany, but with my dad he has all ways referred to himself as a "mutt and proud" and doesn't know his exact origin. My dad has never expressed caring enough to know. We both think that if you are born in America, your parents live in America, and you are surrounded with the culture then you should classify yourself as an American. Simply due to the fact that America thrived on immigration, so in a way we all descended from immigrants in one way or another (if your born in America and have .
1)When describing my ethnicity, I have a tendency to describe myse.docx
1. 1)When describing my ethnicity, I have a tendency to describe
myself as multiethnic. However, I will say where my mom is
from most of the times which is Italy and Germany, but with my
dad he has all ways referred to himself as a "mutt and proud"
and doesn't know his exact origin. My dad has never expressed
caring enough to know. We both think that if you are born in
America, your parents live in America, and you are surrounded
with the culture then you should classify yourself as an
American. Simply due to the fact that America thrived on
immigration, so in a way we all descended from immigrants in
one way or another (if your born in America and have lived
your whole life living the culture). Then going to how does my
ethnicity compare to that of the people I surround myself with,
would also be considered multiethnic. I say this because I have
friends who were all born and raised in America, now their
grandparents may have directly immigrated to America, and
they may consider themselves a different ethnicity, however
most of them will admit they either don't know their origin, or
they do and it is multiethnic. I feel like being an American we
may not have as strict rules on marriage as other countries. For
instances on my moms side her mom was Italian, and her father
German, and my great-grandparents forbid that they married
each other, due to not being the same ethnicity. Anyhow they
still ended up coming to America and getting married. Which is
very acceptable in American culture.
2) I would describe my ethnicity as an Italian American. My
family on my Father's side migrated from Sicily to New York
when my Grandma was a kid. I grew up in a very traditional
Italian household. The woman of the house which was my
Grandmother was the homemaker which included taking care of
her two children, cooking, and cleaning. My Grandpa was a man
of few words, but a hard worker and military veteran. The house
was always loud with people in and out. Family get-togethers
were large and always included a lot of Italian food and a lot of
2. cursing. My Mother, on the other hand, is only a small
percentage of Italian. My mother and my children are who I
spend most of my time with now. My children's father is
German American. Our family blends together just fine,
however, I am typically the loudest and most outspoken.
3)When describing my ethnicity, I have a tendency to describe
myself as multiethnic. However, I will say where my mom is
from most of the times which is Italy and Germany, but with my
dad he has all ways referred to himself as a "mutt and proud"
and doesn't know his exact origin. My dad has never expressed
caring enough to know. We both think that if you are born in
America, your parents live in America, and you are surrounded
with the culture then you should classify yourself as an
American. Simply due to the fact that America thrived on
immigration, so in a way we all descended from immigrants in
one way or another (if your born in America and have lived
your whole life living the culture). Then going to how does my
ethnicity compare to that of the people I surround myself with,
would also be considered multiethnic. I say this because I have
friends who were all born and raised in America, now their
grandparents may have directly immigrated to America, and
they may consider themselves a different ethnicity, however
most of them will admit they either don't know their origin, or
they do and it is multiethnic. I feel like being an American we
may not have as strict rules on marriage as other countries. For
instances on my moms side her mom was Italian, and her father
German, and my great-grandparents forbid that they married
each other, due to not being the same ethnicity. Anyhow they
still ended up coming to America and getting married. Which is
very acceptable in American culture.
Rather than writing a complete method and then testing it, test-
driven development involves writing the tests and the method in
parallel. The sequence is as follows:
· Write a test case for a feature.
· Run the test and observe that it fails, but other tests still pass.
3. · Make the minimum change necessary to make the test pass.
· Revise the method to remove any duplication between the code
and the test.
· Rerun the test to see that it still passes.
We then repeat these steps adding a new feature until all of the
requirements for the method have been implemented.
We will use this approach to develop a method to find the first
occurrence of a target in an array.
Case Study: Test-Driven Development of ArraySearch.search
Write a program to search an array that performs the same way
as Java method ArraySearch.search. This method should return
the index of the first occurrence of a target in an array,
or −1−1 if the target is not present.
We start by creating a test list like that in the last section and
then work through them one at a time. During this process, we
may think of additional tests to add to the test list.
Our test list is as follows:
1. The target element is not in the list.
2. The target element is the first element in the list.
3. The target element is the last element in the list.
4. There is more than one occurrence of the target element and
we find the first occurrence.
5. The target is somewhere in the middle.
6. The array has only one element.
7. The array has no elements.
We start by creating a stub for the method we want to code:
/**
* Provides a static method search that searches an array
* @author Koffman & Wolfgang
*/
public class ArraySearch {
/**
* Search an array to find the first occurrence of a target
* @param x Array to search
* @param target Target to search for
* @return The subscript of the first occurrence if found:
4. * otherwise return -1
* @throws NullPointerException if x is null
*/
public static int search(int[] x, int target) {
return Integer.MIN_VALUE;
}
}
Now, we create the first test that combines tests 1 and 6 above.
We will screen the test code in gray to distinguish it from the
search method code.
/**
* Test for ArraySearch class
* @author Koffman & Wolfgang
*/
public class ArraySearchTest {
@Test
public void itemNotFirstElementInSingleElementArray() {
int[] x = {5};
assertEquals(-1, ArraySearch.search(x, 10));
}
}
And when we run this test, we get the message:
Testcase: itemNotFirstElementInSingleElementArray: FAILED
expected:<-1> but was:<-2147483648>
The minimum change to enable method search to pass the test is
public static int search(int[] x, int target) {
return -1; // target not found
}
Now, we can add a second test to see whether we find the target
in the first element (tests 2 and 6 above).
@Test
public void itemFirstElementInSingleElementArray() {
5. int[] x = new int[]{5};
assertEquals(0, ArraySearch.search(x, 5));
}
As expected, this test fails because the search method returns
−1. To make it pass, we modify our search method:
public static int search(int[] x, int target) {
if (x[0] == target) {
return 0; // target found at 0
}
return -1; // target not found
}
Both tests for a single element array now pass. Before moving
on, let us see whether we can improve this. The process of
improving code without changing its functionality is known
as refactoring. Refactoring is an important step in test-driven
development. It is also facilitated by TDD since having a
working test suite gives you the confidence to make changes.
(Kent Beck, a proponent of TDD says that TDD gives
courage.1)
The statement:
return 0;
is a place for possible improvement. The value 00 is the index
of the target. For a single element array this is obviously 00, but
for larger arrays it may be different. Thus, an improved version
is
public static int search(int[] x, int target) {
int index = 0;
if (x[index] == target)
return index; // target at 0
return -1; // target not found
}
Now, let us see whether we can find an item that is last in a
larger array (test 3 above). We start with a 2-element array:
@Test
6. public void itemSecondItemInTwoElementArray() {
int[] x = {10, 20};
assertEquals(1, ArraySearch.search(x, 20));
}
The first two tests still pass, but the new test fails. As expected,
we get the message:
Testcase: itemSecondItemInTwoElementArray: FAILED
expected:<1> but was:<-1>
The test failed because we did not compare the second array
element to the target. We can modify the method to do this as
shown next.
public static int search(int[] x, int target) {
int index = 0;
if (x[index] == target)
return index; // target at 0
index = 1;
if (x[index] == target)
return index; // target at 1
return -1; // target not found
}
However, this would result in
an ArrayOutOfBoundsException error for
test itemNotFirstElementInSingleElementArraybecause there is
no second element in the array {5}. If we change the method to
first test that there is a second element before comparing it to
target, all tests will pass.
public static int search(int[] x, int target) {
int index = 0;
if (x[index] == target)
return index; // target at 0
index = 1;
if (index < x.length) {
if (x[index] == target)
return index; // target at 1
}
return -1; // target not found
7. }
However, what happens if we increase the number of elements
beyond 2?
@Test
public void itemLastInMultiElementArray() {
int[] x = new int[]{5, 10, 15};
assertEquals(2, ArraySearch.search(x, 15));
}
This test would fail because the target is not at position 0 or 1.
To make it pass, we could continue to add ifstatements to test
more elements, but this is a fruitless approach. Instead, we
should modify the code so that the value of index advances to
the end of the array. We can change the second if to a while and
add an increment of index.
public static int search(int[] x, int target) {
int index = 0;
if (x[index] == target)
return index; // target at 0
index = 1;
while (index < x.length) {
if (x[index] == target)
return index; // target at index
index++;
}
return -1; // target not found
}
At this point, we have a method that will pass all of the tests for
any size array. We can group all the tests in a single testing
method to verify this.
@Test
public void verificationTests() {
int[] x = {5, 12, 15, 4, 8, 12, 7};
// Test for target as first element
assertEquals(0, ArraySearch.search(x, 5));
8. // Test for target as last element
assertEquals(6, ArraySearch.search(x, 7));
// Test for target not in array
assertEquals(-1, ArraySearch.search(x, -5));
// Test for multiple occurrences of target
assertEquals(1, ArraySearch.search(x, 12));
// Test for target somewhere in middle
assertEquals(3, ArraySearch.search(x, 4));
}
Although it may look like we are done, we are not finished
because we also need to check that an empty array will always
return −1:
@Test
public void itemNotInEmptyArray() {
int[] x = new int[0];
assertEquals(-1, ArraySearch.search(x, 5));
}
Unfortunately, this test does not pass because of
an ArrayIndexOutofboundsException in the first if condition for
method search (there is no element x[0] in an empty array). If
we look closely at the code for search, we see that the initial
test for when index is 0 is the same as for the other elements.
So we can remove the first statement and start the loop
at 0instead of 1 (another example of refactoring). Our code
becomes more compact and this test will also pass. A slight
improvement would be to replace the while with a for statement.
public static int search(int[] x, int target) {
int index = 0;
while (index < x.length) {
if (x[index] == target)
return index; // target at index
index++;
}
return -1; // target not found
}
9. Finally, if we pass a null pointer instead of a reference to an
array, a NullPointerException should be thrown (an additional
test not in our original list).
@Test(expected = NullPointerException.class)
public void nullValueOfXThrowsException() {
assertEquals(0, ArraySearch.search(null, 5));
}
JUnit in Netbeans
It is fairly easy to create a JUnit test harness in Netbeans. Once
you have written class ArraySearch.java, right click on the class
name in the Projects view and then select Tools −>
Create/Update Tests. A Create Tests window will pop up. Select
OK and then a Select JUnit Version window will pop up: select
the most recent version of JUnit (currently JUnit 4.x). At this
point, a new class will be created (ArraySearchTest.java) that
will contain prototype tests for all the public functions in
class ArraySearch. You can replace the prototype tests with
your own. To execute the tests, right click on
class ArraySearchTest.
ASSIGNMENT
EXERCISES FOR SECTION 3.5
SELF-CHECK
1. Why did the first version of method search that passed the
first test itemNotFirstElementInSingleElementArraycontain
only the statement return −1?
2. Assume the first JUnit test for the findLargest method
described in Self-Check exercise 2 in section 3.4 is a test that
determines whether the first item in a one element array is the
largest. What would be the minimal code for a
method findLargest that passed this test?
PROGRAMMING
10. 1. Write the findLargest method described in self-check
exercise 2 in section 3.4 using Test-Driven Development.
Date: April 03, 2019.
Start time: 2.30 End time: 4:30
Assignment: Theater
Describe the environment:
Location (name): BAPS Templ
e Location Address: 12305 Natural bridge road Bridgeton
Location City: Missouri
Location State: st.louis
Location Neighborhood (what type of neighborhood is it?
What are the defining characteristics about the environment or
the neighborhood?
Location building style (outside): The building, inside and
outside. Size, building style, materials used, architecture,
geographic orientation, décor. Is the building oriented to a
specific compass direction—more important for religions.
Location building style (inside): describe the interior colors,
layout, room size, room use, room restrictions, multiple levels,
décor, disbursement of information, use of symbols and icons,
art or advertisements.
Smoking or non-smoking: it was a non-smoking area as
families and younger people were also viewing movie.. Type of
event: celebrate swami’s Jayanti and tell about his life style
11. Event details: the event was a play how the only person can his
whole life to help poor people. Small kids was performed in the
theater.
To what degree were you already familiar with this type of
event: I was not very well aware because I have watched the
movies on theatres but never a live performance movie.
Who did you attend the event with: I attended this event with
my family and friends. _
The worship and performance rooms:
How big are they: the theater hall is approximately 9m × 5m
with additional 10m × 7m stage (width × height)
How many could they accommodate: roughly 400 people can be
accommodated. Are there seating arrangements: there
were appropriate seating arrangements.
How many windows: due to the necessity of multimedia screens
and stage lightning, there were no windows. Describe the
lighting: There is a light for stage coverage. The audience
remained splendidly under coverage. Colors used: red
Where is the focal point: stage
How well does sound travel: sound was effectively managed so
people could have clear audio of the performance.
What was the reverence of participants in the space: the
participants were involved in the performance and were
watching with interest. Is there an alter, shrine, or stage:
there is a stage. What scents or smells do you notice:
the fresheners were used by management. What
symbols did you notice: BAPS name logo What
ritual objects did you see:
Describe the participants: (use additional paper if needed)
12. Estimate the total number of participants: 400
Estimate the total number of participants by race and age, and
gender:
White (total) 150 Gender total: m 90 f 60
0-10 m f 11-15 m f 16-18 m f 19-25 m f 40
26-35 m f 20 36-45_ m 60 f 46-55 m 30 f _56-65
m f
66-75 m f 76+ m f
Black (total) 120 Gender total: m 80 f 40
0-10 m f 11-15 m f 16-18 m f 19-25 m 30 f
30
26-35 m 50 f 10 36-45_ m f 46-55 m f _56-65 m f
66-75 m f 76+ m f
Asian (total) 130 Gender total: m 100 f 30
0-10 m f 11-15 m f 16-18 m 50 f 10 19-25 m 25
f 20
26-35 m 50 f 10 36-45_ m 25 f 46-55 m f _56-65
m f
66-75 m f 76+ m f
Native American (total)
0-10 m f 11-15 m f 16-18 m f 19-25 m f
26-35 m f 36-45_ m f 46-55 m f _56-65 m f
66-75 m f 76+ m f
Asian Pacific Islander (total) Gender total: m f
0-10 m f 11-15 m f 16-18 m f 19-25 m f
26-35 m f 36-45_ m f 46-55 m f _56-65 m f
13. 66-75 m f 76+ m f
What did the participants do: (e.g. sing, read, stand, sit, recite,
chant, meditate, listen, pray, applaud etc.)
they watched the performance with interest and listened to the
voice over.
What is the primary language spoken? Hindi, English, Tamil,
Punjabi
Were there multiple activities? yes
How long was each of the different activities? There was on a
performance that depicted a multiple story.
Describe your interaction with the people: (use additional
paper)
I loved watching such a lovely live performance and was
touched by the story that provided a message for the viewers. It
was a very good experience and I really enjoyed this
performance.
How did the children act? The younger ones also found it
interesting they act nicely.
What were the participants wearing? Casual clothing.
Who lead the activity? there was a host that guided
the whole performance. Gender female Age 25 What
were they wearing? Traditional clothes
14. Did you speak with anybody?
Name , status religious leader Lay leader ,
just an ordinary follower What did you discuss?
Do they have printed information:
What printed information did you collect: You should
collect printed information to substantiate your attendance to
this activity. What printed information was distributed or
available? Include these items with your report.
What notes do you have about your experience?
I like to understand differ religious.
How did the event make you feel?
this event assisted in having a peaceful time with light
entertainment.
How does this experience compare to experiences with which
you are more familiar?
this experience was more of a peaceful entertainment and I
found myself more involved as compared to others that I am
familiar with.
What are your general impressions: can you infer any
information about gender stratification, disparity in wealth,
racial segregation or any other social issues we have discussed
throughout the course?
I loved this performance do much. The whole presentation was
admirable, the stage, actors and lightning in a complete package
added to the feel of this performance. However, no issues could
be observed in this performance.
15. Take a selfie of you at the event. Insert your selfie here:
Take a picture of the venue. Insert the picture here:
Other notes:
17. Assignment: Theater
Describe the environment:
Location (name): BAPS Templ
e Location Address: 12305 Natural bridge road Bridgeton
Location City: Missouri
Location State: st.louis
Location Neighborhood (what type of neighborhood is it?
What are the defining characteristics about the environment or
the neighborhood?
Location building style (outside): The building, inside and
outside. Size, building style, materials used, architecture,
geographic orientation, décor. Is the building oriented to a
specific compass direction—more important for religions.
Location building style (inside): describe the interior colors,
layout, room size, room use, room restrictions, multiple levels,
décor, disbursement of information, use of symbols and icons,
art or advertisements.
Smoking or non-smoking: it was a non-smoking area as
families and younger people were also viewing movie.. Type of
event: celebrate swami’s Jayanti and tell about his life style
Event details: the event was a play how the only person can his
whole life to help poor people. Small kids was performed in the
theater.
To what degree were you already familiar with this type of
event: I was not very well aware because I have watched the
movies on theatres but never a live performance movie.
18. Who did you attend the event with: I attended this event with
my family and friends. _
The worship and performance rooms:
How big are they: the theater hall is approximately 9m × 5m
with additional 10m × 7m stage (width × height)
How many could they accommodate: roughly 400 people can be
accommodated. Are there seating arrangements: there
were appropriate seating arrangements.
How many windows: due to the necessity of multimedia screens
and stage lightning, there were no windows. Describe the
lighting: There is a light for stage coverage. The audience
remained splendidly under coverage. Colors used: red
Where is the focal point: stage
How well does sound travel: sound was effectively managed so
people could have clear audio of the performance.
What was the reverence of participants in the space: the
participants were involved in the performance and were
watching with interest. Is there an alter, shrine, or stage:
there is a stage. What scents or smells do you notice:
the fresheners were used by management. What
symbols did you notice: BAPS name logo What
ritual objects did you see:
Describe the participants: (use additional paper if needed)
Estimate the total number of participants: 400
Estimate the total number of participants by race and age, and
gender:
White (total) 150 Gender total: m 90 f 60
0-10 m f 11-15 m f 16-18 m f 19-25 m f 40
26-35 m f 20 36-45_ m 60 f 46-55 m 30 f _56-65
m f
66-75 m f 76+ m f
19. Black (total) 120 Gender total: m 80 f 40
0-10 m f 11-15 m f 16-18 m f 19-25 m 30 f
30
26-35 m 50 f 10 36-45_ m f 46-55 m f _56-65 m f
66-75 m f 76+ m f
Asian (total) 130 Gender total: m 100 f 30
0-10 m f 11-15 m f 16-18 m 50 f 10 19-25 m 25
f 20
26-35 m 50 f 10 36-45_ m 25 f 46-55 m f _56-65
m f
66-75 m f 76+ m f
Native American (total)
0-10 m f 11-15 m f 16-18 m f 19-25 m f
26-35 m f 36-45_ m f 46-55 m f _56-65 m f
66-75 m f 76+ m f
Asian Pacific Islander (total) Gender total: m f
0-10 m f 11-15 m f 16-18 m f 19-25 m f
26-35 m f 36-45_ m f 46-55 m f _56-65 m f
66-75 m f 76+ m f
What did the participants do: (e.g. sing, read, stand, sit, recite,
chant, meditate, listen, pray, applaud etc.)
they watched the performance with interest and listened to the
voice over.
What is the primary language spoken? Hindi, English, Tamil,
Punjabi
20. Were there multiple activities? yes
How long was each of the different activities? There was on a
performance that depicted a multiple story.
Describe your interaction with the people: (use additional
paper)
I loved watching such a lovely live performance and was
touched by the story that provided a message for the viewers. It
was a very good experience and I really enjoyed this
performance.
How did the children act? The younger ones also found it
interesting they act nicely.
What were the participants wearing? Casual clothing.
Who lead the activity? there was a host that guided
the whole performance. Gender female Age 25 What
were they wearing? Traditional clothes
Did you speak with anybody?
Name , status religious leader Lay leader ,
just an ordinary follower What did you discuss?
Do they have printed information:
What printed information did you collect: You should
collect printed information to substantiate your attendance to
21. this activity. What printed information was distributed or
available? Include these items with your report.
What notes do you have about your experience?
I like to understand differ religious.
How did the event make you feel?
this event assisted in having a peaceful time with light
entertainment.
How does this experience compare to experiences with which
you are more familiar?
this experience was more of a peaceful entertainment and I
found myself more involved as compared to others that I am
familiar with.
What are your general impressions: can you infer any
information about gender stratification, disparity in wealth,
racial segregation or any other social issues we have discussed
throughout the course?
I loved this performance do much. The whole presentation was
admirable, the stage, actors and lightning in a complete package
added to the feel of this performance. However, no issues could
be observed in this performance.
Take a selfie of you at the event. Insert your selfie here:
22. Take a picture of the venue. Insert the picture here:
Other notes: