4 C#, Java, and Objective-C include optimized logical operators

advertisement
Best Practices for Small Device Programming
Assignment 03
20 points
Exercises
1. Complete #1 and #4 of the "Up for Discussion" topics on p. 70 of the textbook. Be sure to
compose thoughtful responses to the questions in a Word document (.doc or .docx).
#1 Discuss the relationship between a class and an object.
A class is a template for creating objects, it defines the most fundamental attributes that an object
has. An object comes from these classes with data filling these attributes, giving an object its
unique characteristics.
#4 C#, Java, and Objective-C include optimized logical operators. Why is this feature important?
If logical operators weren't optimized, how would you structure conditional statements to best
optimize them?
Optimized logical operators help an app or program to use less memory and run faster.
For example if your program uses a lot of strings that’s values change, using mutable string
buffers will delete the old values and give the strings a completely new value.
2. Complete #1 of the "Programming Exercises" on p. 70 of the textbook. Upload the source
code to the dropbox for this assignment.
#1 Using the programming language of your choice, create a class for Triangle objects. This
Triangle class implement its own getArea() and getPerimeter() methods. Create a program to test
your Triangle class to display the data. Hint: To find a triangle's area, use the following formula
(given three sides):
def main():
s1 = input("enter value for side 1 ")
s2 = input("enter value for side 2 ")
s3 = input("enter value for side 3 ")
class Triangle:
def__init__(self, side1, side2, side3):
self.__side1 = side1
self.__side2 = side2
self.__side3 = side3
def set_sidesp(self, side1, side2, side3):
self.__sidesp = (side1 + side2 + side3)
def set_sidesa(self, side1, side2, side3):
s = (side1 + side2 + side3)/2
def getPerimeter(self):
return self.__sidesp
def getArea(self, side1, side2, side3):
return Math.sqrt(s * (s - side1) * (s - side2) * (s - side3))
}
3. Upload the document and the zipped source code to the dropbox for this assignment before the
posted due date.
Name 7 things you can do to secure your phone.
1. Lock your screen with a pass code. If anyone finds the phone they won’t have access to your
information without a password.
2. Have your phone encrypt the data that is stored on it.
3. Remote wipe. Allows you to erase all data that is stored from anywhere.
4. Having voice encryption will not allow others outside a call to hear your conversations.
5. GPS tracking. Allows the phone to be located when lost.
6. Using alpha numeric passcodes, or passwords that are harder to crack.
7. If a user fails to enter the correct passcode have the phone auto erase function.
Download