From 4cc6bcb7e82bf35ce933d241d4f1c18cb3c234b4 Mon Sep 17 00:00:00 2001 From: Avery Ng Date: Tue, 16 Sep 2025 11:54:16 -0400 Subject: [PATCH] task 1: changed int to long --- README.md | 10 +++++----- src/DataTypes.java | 5 +++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 49ad8cf6..d6303eb5 100644 --- a/README.md +++ b/README.md @@ -25,14 +25,14 @@ Your TA will share a different URL for you to fork from, so that you can make pull requests to that repo during Task 3 of the lab. If you miss the lab and work on this after, you can use this URL though. -- [ ] Make a fork of this repo and clone a local copy (as you did in Lab 1). +- [x] Make a fork of this repo and clone a local copy (as you did in Lab 1). >**Important**: make sure to uncheck the option to only fork the main branch, as the repo > contains two branches you will use later in this lab. # TASK 1: Your first branch -- [ ] Create and checkout a new branch called `task_1` using either IntelliJ or the Terminal: +- [x] Create and checkout a new branch called `task_1` using either IntelliJ or the Terminal: - IntelliJ: `Git -> New branch...` - Terminal: `git checkout -b task_1` - After, you can check `git status` or the Log tab of the Git tool window in IntelliJ to see @@ -40,17 +40,17 @@ If you miss the lab and work on this after, you can use this URL though. --- -- [ ] Open the TODO tool window (`View -> Tool Windows -> TODO`) and click on the TASK 1 TODO listed. +- [x] Open the TODO tool window (`View -> Tool Windows -> TODO`) and click on the TASK 1 TODO listed. --- -- [ ] Complete the TASK 1 TODO and commit your changes to this file (checking off the +- [x] Complete the TASK 1 TODO and commit your changes to this file (checking off the completed items so far) and `DataTypes.java` (remove the word TODO and your bug fix). - talk to your team or your TA, then see the hints at the bottom of the readme if you get stuck. --- -- [ ] Now, we'll merge the `task_1` branch back into `main`. When merging, +- [x] Now, we'll merge the `task_1` branch back into `main`. When merging, you need to be currently on the branch you are trying to merge into, so we'll first check out the main branch: - IntelliJ: `Git -> branches... -> main -> Checkout` diff --git a/src/DataTypes.java b/src/DataTypes.java index 12c0618e..933d25de 100644 --- a/src/DataTypes.java +++ b/src/DataTypes.java @@ -1,8 +1,9 @@ public class DataTypes { - // TODO TASK 1: fix this code so that it passes the test in DataTypesTest.java public static long sum(int[] numbers) { - int s = 0; // variable to accumulate the sum in! + long s = 0L; // variable to accumulate the sum in! // below is a "foreach" loop which iterates through numbers + // error: bit overflow as we went over the amount of the int limit + // int s = 0 -> long s = 0L for (int x : numbers) { s += x; }