EECS1022Lab02 - EECS 1022, lab 2 topic and manual PDF

Title EECS1022Lab02 - EECS 1022, lab 2 topic and manual
Author minh tuyet
Course Programming for Mobile Computing
Institution York University
Pages 24
File Size 1 MB
File Type PDF
Total Downloads 41
Total Views 140

Summary

EECS 1022, lab 2 topic and manual...


Description

EECS1022 - Lab02 Due Date: Friday February 4, 2022 before 22:00 Contents Instructions: .................................................................................................................................... 2 Important Reminders .................................................................................................................. 2 Academic Honesty ...................................................................................................................... 2 Learning Objectives ......................................................................................................................... 3 Important pre-lab works you need to do before going to the lab ................................................. 3 Part One: Style Rules ....................................................................................................................... 4 Part Two: Lab Structure .................................................................................................................. 7 Part Three: Lab Exercise ................................................................................................................. 8 Design:......................................................................................................................................... 8 Task1 Design: .......................................................................................................................... 9 Task2 Design: .......................................................................................................................... 9 Task3 Design: .......................................................................................................................... 9 Task4 Design: .......................................................................................................................... 9 Setting up the project: .............................................................................................................. 10 Task1 Implementation: ......................................................................................................... 14 Task2 Implementation: ......................................................................................................... 15 Task3 Implementation: ......................................................................................................... 16 Task4 Implementation: ......................................................................................................... 17 Verify and Test Your Implementation Using JUnit Test Cases ...................................................... 18 Submit your work by using the course eClass .............................................................................. 22 Check List: ................................................................................................................................. 22 Submit The Following Files: ...................................................................................................... 23 Post-Lab Tasks (This part is not submitted and will not be graded) ............................................. 24

Page 1 of 24

EECS1022 - Lab02 Due Date: Friday February 4, 2022 before 22:00

Instructions: Important Reminders •



You should attend your own lab session (the one you are enrolled in). If you need to change your lab enrollment, you should contact the Undergraduate Office in the department. Instructors or TAs cannot change your enrollment. You can submit your lab work in eClass any time before 22:00 on Friday (February 4, 2022) of the week the lab is due. Your last submission will overwrite the previous ones, and only the last submission will be graded.









The deadline is strict with no excuses: you receive 0 for not making your electronic submission in time. Emailing your solutions to the instructors or TAs will not be acceptable. Part of your submission for this lab is the design of your solution. This part is graded by TAs and constitutes 20% of your grade in the lab. The remaining 80% is for the implementation part of your solution and will be graded by JUnit tests given to you and additional JUnit tests covering some other input values. This is to encourage you to take more responsibility for the correctness of your code by writing your own JUnit tests. Developing and submitting a correct solution for this lab without compilation errors is essential. Hence, it's important you take a reasonable amount of time to test your code in different ways. If you submitted a solution with any mistake in terms of syntax or not complying with lab instructions, then you may receive 0 as a grade for the implementation of this lab You will still be allowed a second attempt with a 30% penalty to submit your implementation code (.java files) for this lab. The second attempt will be open on Sunday, two days after the original due date of this lab. During these two days, you will receive feedback about your first attempt. So, you will have an opportunity of ~ 48 hours to correct your implementation if you have any errors such as compilation errors, wrong submission, etc. Note that if you make a second attempt, there will be a 30% penalty and whatever grade you achieve (even if lower than that of your first attempt) will be your final grade.

Academic Honesty • •

Students are expected to read the Senate Policy on Academic Honesty. See also the EECS Department Academic Honesty Guidelines. All labs are to be completed individually: no group work is allowed. Do not discuss solutions with anyone other than the instructor or the TAs. Do not copy or look at specific solutions from the net. If you are repeating the course, you are not allowed to submit your own solution developed in previous terms or for other purposes. You should start from scratch and follow the instructions.

Page 2 of 24

EECS1022 - Lab02 Due Date: Friday February 4, 2022 before 22:00

Learning Objective Objectivess • • • • • • • •

To be familiar with coding style To be able to use Java data types, values, and variables To program with assignment statements and expressions To perform operations using operators +, -, *, /, and % To create a static (Utilities) class where all methods are static To use Java control structures (selections, loops, and nested loops) To use JUnit Tests to verify your work To create methods based on a given API

Important pre-lab works you need to do before going to the lab a. Make sure you have IntelliJ IDEA IDE installed on your machine a. https://www.jetbrains.com/help/idea/2021.3/installation-guide.html b. https://www.jetbrains.com/help/idea/2021.3/run-for-the-first-time.html b. Read about Create your first Java application using IntelliJ IDEA a. https://www.jetbrains.com/help/idea/creating-and-running-your-firstjava-application.html c. Testing in IntelliJ IDEA a. https://www.jetbrains.com/help/idea/tests-in-ide.html b. https://youtu.be/Bld3644bIAo Feel free to find online resources on these and share them with your classmate on the discussion forum.

Page 3 of 24

EECS1022 - Lab02 Due Date: Friday February 4, 2022 before 22:00

Part One: Style Rules The style rules are not overly restrictive in EECS1022. 1. Your programs should follow the standard Java conventions (class names begin with an uppercase letter, variable names start with a lowercase letter, public static final constants should be in all caps, etc.). 2. In general, use short but descriptive variable names. There are exceptions to this rule; for example, traditional loop variables are often called i, j, k, etc. 3. For long names, use the camelCase style. Yet, avoid very long names; they are hard to read, take up too much screen space, and easily mistype. 4. Use a consistent indentation size. Beware of the TAB vs SPACE problem: Tabs have no fixed size; one editor might interpret a tab as four spaces, and another might use eight spaces. If you mix tabs and spaces, you will have indenting errors when your code is viewed in different editors. 5. Your code should include Javadoc comments. Every documentation comment begins with: "/**"

and ends with "*/" A one-line comment begins with "//" •



Use one-line comments to explain implementation details such as the purpose of specific variables and expressions. int iCountPer=0; //counts persons Explain local variable declarations with an end-line comment.

6. Use a consistent brace style: // left-aligned braces class X { public void someMethod() { // ... } public void anotherMethod() { for (int i = 0; i < 1; i++) { // ...

Page 4 of 24

EECS1022 - Lab02 Due Date: Friday February 4, 2022 before 22:00 } } }

or // ragged braces class X { public void someMethod() { // ... } public void anotherMethod() { for (int i = 0; i < 1; i++) { // ... } } }

7. Insert a space around operators (except the period "."). The following // some code somewhere boolean isBetween = (x > MIN_VALUE) && (x > MAX_VALUE); int someValue = x + y * z;

is much easier to read than this // AVOID DOING THIS // some code somewhere boolean isBetween=(x>MIN_VALUE)&&(x>MAX_VALUE); int someValue=x+y*z;

Page 5 of 24

EECS1022 - Lab02 Due Date: Friday February 4, 2022 before 22:00 8. Avoid using "magic numbers". A magic number is a number that appears in a program in place of a named constant. For example, consider the following code: int n = 7 * 24;

What do the numbers 7 and 24 mean? Compare the code above to the following: final int DAYS_PER_WEEK = 7; final int HOURS_PER_DAY = 24; int n = DAYS_PER_WEEK * HOURS_PER_DAY;

In the second example, the meaning of 7 and 24 is now clear (better yet, rename n). In general, hardcoding is discouraged. Not all numbers are magic numbers. You can usually use 0, 1, and 2 without creating a named constant. If you ever find yourself doing something like: final int TEN = 10;

Then, you are probably better off using 10 and explaining its meaning in a comment. 9. A good IDE (integrated development environment) such as IntelliJ IDEA and Eclipse will correct many style errors for you. In IntelliJ IDEA, you can select the code that you want to format, then choose code -> Reformat Code to format your code automatically. However, we strongly recommend that you fix the errors manually for the benefit of learning.

Page 6 of 24

EECS1022 - Lab02 Due Date: Friday February 4, 2022 before 22:00

Part Two: Lab Structure Download the starter code "Lab2.zip" from the eClass course site The lab folder/directory structure is as follows: • src/lab2/: directory contains a Java file named Utilities.java. • junit_tests/lab2/: directory contains a Java file (JUnit test cases) named UtilitiesTest.java. This file contains several JUnit test cases that can help to test your code. It should be noted that you need to tun the JUnit tester UtilitiesTest.java after you complete the Utilities class to check your work. Nonetheless, passing all given tests does not guarantee full marks for this lab. Therefore, you are required to write additional tests to ensure the correctness of your implementations. • doc/: directory contains Java documentations for lab2 in HTML format.

Page 7 of 24

EECS1022 - Lab02 Due Date: Friday February 4, 2022 before 22:00

Part Three: Lab Exerc Exercise ise In this lab, you need to design and implement four tasks (static methods). The design part will be carried out using pseudocode and/or flowchart, and the implementation part will be carried out using Java programming language.

Design: An algorithm is an organized sequence of the actions to be executed to solve a problem/task. Those actions need to be ordered in a logical execution sequence to solve the given problem. Hence, an algorithm is merely the sequence of steps taken to solve a problem. Pseudocode is an informal language that helps programmers develop algorithms. Pseudocode is a "text-based" detail (algorithmic) design tool. The rules of pseudocode are reasonably straightforward. All statements showing "dependency" are to be indented. These include while, do, for, if, switch. The example below will illustrate this notion. (Ref: Planning with pseudocode) Example1: Assume you want to design an algorithm to calculate the average of n integer numbers Algorithm average_of_Numbers (list of n integer values) Pre-conditions: n in in N and >0; inputs are in N as well Post-Conditions: the average of inputs is returned Input n integers Output average of n Inetger total...


Similar Free PDFs