From 11bf9ba922192d9dc43eb0588c705f70e5dd3985 Mon Sep 17 00:00:00 2001 From: LauraV702 Date: Fri, 3 Jan 2025 08:37:45 -0800 Subject: [PATCH 01/53] Initial comment for testing purpose --- src/ArrayPractice.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ArrayPractice.java b/src/ArrayPractice.java index bc58c83..7491105 100644 --- a/src/ArrayPractice.java +++ b/src/ArrayPractice.java @@ -1,5 +1,6 @@ public class ArrayPractice { public static void main(String[] args) { + // testing comment // Create an array of Strings of size 4 // Set the value of the array at each index to be a different String From 3602d0f07cf51d68cd57a7d67a2b218fa9d59579 Mon Sep 17 00:00:00 2001 From: LauraV702 Date: Fri, 3 Jan 2025 08:38:30 -0800 Subject: [PATCH 02/53] Removed testing comment --- src/ArrayPractice.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/ArrayPractice.java b/src/ArrayPractice.java index 7491105..bc58c83 100644 --- a/src/ArrayPractice.java +++ b/src/ArrayPractice.java @@ -1,6 +1,5 @@ public class ArrayPractice { public static void main(String[] args) { - // testing comment // Create an array of Strings of size 4 // Set the value of the array at each index to be a different String From 7393237c8528e5be7547264668fe5ff83075c182 Mon Sep 17 00:00:00 2001 From: LauraV702 Date: Fri, 3 Jan 2025 08:41:24 -0800 Subject: [PATCH 03/53] Created a new array of strings with size 4 --- src/ArrayPractice.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ArrayPractice.java b/src/ArrayPractice.java index bc58c83..235823c 100644 --- a/src/ArrayPractice.java +++ b/src/ArrayPractice.java @@ -1,7 +1,7 @@ public class ArrayPractice { public static void main(String[] args) { // Create an array of Strings of size 4 - + String[] arrayFour = new String[4]; // Set the value of the array at each index to be a different String // It's OK to do this one-by-one From 56707657c1f1812d956f9b7962f3150ad233e3fe Mon Sep 17 00:00:00 2001 From: LauraV702 Date: Fri, 3 Jan 2025 08:46:31 -0800 Subject: [PATCH 04/53] Set each index with its own string --- src/ArrayPractice.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/ArrayPractice.java b/src/ArrayPractice.java index 235823c..3638449 100644 --- a/src/ArrayPractice.java +++ b/src/ArrayPractice.java @@ -1,10 +1,13 @@ public class ArrayPractice { public static void main(String[] args) { // Create an array of Strings of size 4 - String[] arrayFour = new String[4]; + String[] arrayFour = new String[4]; // Set the value of the array at each index to be a different String // It's OK to do this one-by-one - + arrayFour[0] = "ZERO"; + arrayFour[1] = "ONE"; + arrayFour[2] = "TWO"; + arrayFour[3] = "THREE"; // Get the value of the array at index 2 // Get the length of the array From 08022ba87ae82afe171c19cf5bd7c48e7f1b744f Mon Sep 17 00:00:00 2001 From: LauraV702 Date: Fri, 3 Jan 2025 08:52:52 -0800 Subject: [PATCH 05/53] Added print commands to get value of the array at index 2 and length of array --- src/ArrayPractice.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ArrayPractice.java b/src/ArrayPractice.java index 3638449..c6f2c07 100644 --- a/src/ArrayPractice.java +++ b/src/ArrayPractice.java @@ -9,9 +9,9 @@ public static void main(String[] args) { arrayFour[2] = "TWO"; arrayFour[3] = "THREE"; // Get the value of the array at index 2 - + System.out.println(arrayFour[2]); //output: TWO // Get the length of the array - + System.out.println(arrayFour.length); // Iterate over the array using a traditional for loop and print out each item // Iterate over the array using a for-each loop and print out each item From fb8ccb98ccaaf2ce9be9f0d1c9687da1e7ef246a Mon Sep 17 00:00:00 2001 From: LauraV702 Date: Fri, 3 Jan 2025 08:57:27 -0800 Subject: [PATCH 06/53] Added traditional loop to print out each item --- src/ArrayPractice.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ArrayPractice.java b/src/ArrayPractice.java index c6f2c07..3287cc1 100644 --- a/src/ArrayPractice.java +++ b/src/ArrayPractice.java @@ -13,7 +13,9 @@ public static void main(String[] args) { // Get the length of the array System.out.println(arrayFour.length); // Iterate over the array using a traditional for loop and print out each item - + for (int i = 0; i < arrayFour.length; i++) { + System.out.println(arrayFour[i]); + } // Iterate over the array using a for-each loop and print out each item /* From e9b3177d67cbb521385730c7d7fd218fd70e0d56 Mon Sep 17 00:00:00 2001 From: LauraV702 Date: Fri, 3 Jan 2025 09:01:08 -0800 Subject: [PATCH 07/53] Added for-each loop to print out each item --- src/ArrayPractice.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ArrayPractice.java b/src/ArrayPractice.java index 3287cc1..7b6536a 100644 --- a/src/ArrayPractice.java +++ b/src/ArrayPractice.java @@ -17,7 +17,9 @@ public static void main(String[] args) { System.out.println(arrayFour[i]); } // Iterate over the array using a for-each loop and print out each item - + for (String string : arrayFour) { + System.out.println(string); + } /* * Reminder! * From e41db8109670cb946485a7dfa7a2ffe478da12bd Mon Sep 17 00:00:00 2001 From: LauraV702 Date: Fri, 3 Jan 2025 09:04:17 -0800 Subject: [PATCH 08/53] Added space in between for easier readability --- src/ArrayPractice.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/ArrayPractice.java b/src/ArrayPractice.java index 7b6536a..23d7af2 100644 --- a/src/ArrayPractice.java +++ b/src/ArrayPractice.java @@ -2,24 +2,30 @@ public class ArrayPractice { public static void main(String[] args) { // Create an array of Strings of size 4 String[] arrayFour = new String[4]; + // Set the value of the array at each index to be a different String // It's OK to do this one-by-one arrayFour[0] = "ZERO"; arrayFour[1] = "ONE"; arrayFour[2] = "TWO"; arrayFour[3] = "THREE"; + // Get the value of the array at index 2 System.out.println(arrayFour[2]); //output: TWO + // Get the length of the array System.out.println(arrayFour.length); + // Iterate over the array using a traditional for loop and print out each item for (int i = 0; i < arrayFour.length; i++) { System.out.println(arrayFour[i]); } + // Iterate over the array using a for-each loop and print out each item for (String string : arrayFour) { System.out.println(string); } + /* * Reminder! * From 19418472c370c414268df9ecdce27e4de352f7e2 Mon Sep 17 00:00:00 2001 From: LauraV702 Date: Fri, 3 Jan 2025 09:05:41 -0800 Subject: [PATCH 09/53] Completed ArrayPractice --- src/ArrayPractice.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ArrayPractice.java b/src/ArrayPractice.java index 23d7af2..264386a 100644 --- a/src/ArrayPractice.java +++ b/src/ArrayPractice.java @@ -25,11 +25,13 @@ public static void main(String[] args) { for (String string : arrayFour) { System.out.println(string); } - + /* * Reminder! * * Arrays start at index 0 */ + + //DONE } } From e8a40d3f9be5dda5273e3dc1f5882ab423d228cf Mon Sep 17 00:00:00 2001 From: LauraV702 Date: Fri, 3 Jan 2025 09:09:33 -0800 Subject: [PATCH 10/53] Added import for ArrayList and created new ArrayList called stringList --- src/ListPractice.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ListPractice.java b/src/ListPractice.java index f4de8e7..fd805f8 100644 --- a/src/ListPractice.java +++ b/src/ListPractice.java @@ -1,9 +1,11 @@ +import java.util.ArrayList; + public class ListPractice { public static void main(String[] args) { // Create an empty ArrayList of Strings and assign it to a variable of type List - + ArrayList stringList = new ArrayList<>(); // Add 3 elements to the list (OK to do one-by-one) // Print the element at index 1 From 7fdb49c8ceeaa5a566c9f69d5a314f525673cfb1 Mon Sep 17 00:00:00 2001 From: LauraV702 Date: Fri, 3 Jan 2025 09:16:19 -0800 Subject: [PATCH 11/53] Fixed datatype and added 3 elements to the list --- src/ListPractice.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/ListPractice.java b/src/ListPractice.java index fd805f8..85eb337 100644 --- a/src/ListPractice.java +++ b/src/ListPractice.java @@ -5,9 +5,11 @@ public class ListPractice { public static void main(String[] args) { // Create an empty ArrayList of Strings and assign it to a variable of type List - ArrayList stringList = new ArrayList<>(); + ArrayList stringList = new ArrayList<>(); // Add 3 elements to the list (OK to do one-by-one) - + stringList.add("APPLE"); + stringList.add("BANANA"); + stringList.add("KIWI"); // Print the element at index 1 // Replace the element at index 1 with a new value From ad1779089b6dde6cfe4c26024ed1bda5be4a3521 Mon Sep 17 00:00:00 2001 From: LauraV702 Date: Fri, 3 Jan 2025 09:19:58 -0800 Subject: [PATCH 12/53] Added a print command to get the element at index 1 --- src/ListPractice.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ListPractice.java b/src/ListPractice.java index 85eb337..feba898 100644 --- a/src/ListPractice.java +++ b/src/ListPractice.java @@ -11,7 +11,7 @@ public static void main(String[] args) { stringList.add("BANANA"); stringList.add("KIWI"); // Print the element at index 1 - + System.out.println(stringList.get(1)); //output: BANANA // Replace the element at index 1 with a new value // (Do not insert a new value. The length of the list should not change) From a8328be7ef08f945617747b59c34f201e0430248 Mon Sep 17 00:00:00 2001 From: LauraV702 Date: Fri, 3 Jan 2025 09:23:02 -0800 Subject: [PATCH 13/53] Replaced element at index 1, instead of BANANA its now STRAWBERRY --- src/ListPractice.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ListPractice.java b/src/ListPractice.java index feba898..edf6467 100644 --- a/src/ListPractice.java +++ b/src/ListPractice.java @@ -14,7 +14,7 @@ public static void main(String[] args) { System.out.println(stringList.get(1)); //output: BANANA // Replace the element at index 1 with a new value // (Do not insert a new value. The length of the list should not change) - + stringList.set(1, "STRAWBERRY"); // Insert a new element at index 0 (the length of the list will change) // Check whether the list contains a certain string From 5180ae53beeae6372b974b2c0c088d0af75c9b29 Mon Sep 17 00:00:00 2001 From: LauraV702 Date: Fri, 3 Jan 2025 09:32:10 -0800 Subject: [PATCH 14/53] Replaced index at 1 with new value and inserted new element to the list --- src/ListPractice.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ListPractice.java b/src/ListPractice.java index edf6467..69dff8c 100644 --- a/src/ListPractice.java +++ b/src/ListPractice.java @@ -16,7 +16,7 @@ public static void main(String[] args) { // (Do not insert a new value. The length of the list should not change) stringList.set(1, "STRAWBERRY"); // Insert a new element at index 0 (the length of the list will change) - + stringList.add(0, "ORANGE"); // Check whether the list contains a certain string // Iterate over the list using a traditional for-loop. From 852cff5bfd0b4d460fb53616bd3385d6bee94deb Mon Sep 17 00:00:00 2001 From: LauraV702 Date: Fri, 3 Jan 2025 09:33:02 -0800 Subject: [PATCH 15/53] Added if statement to check whether if list contains a certain string --- src/ListPractice.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/ListPractice.java b/src/ListPractice.java index 69dff8c..1dcb884 100644 --- a/src/ListPractice.java +++ b/src/ListPractice.java @@ -18,7 +18,11 @@ public static void main(String[] args) { // Insert a new element at index 0 (the length of the list will change) stringList.add(0, "ORANGE"); // Check whether the list contains a certain string - + if (stringList.contains("AVOCADO")) { + System.out.println("We have avocado :)"); + } else { + System.out.println("There is no avocado :("); + } // Iterate over the list using a traditional for-loop. // Print each index and value on a separate line From d7f63408eed7aba4bf3fe7923110945eacd0b1cb Mon Sep 17 00:00:00 2001 From: LauraV702 Date: Fri, 3 Jan 2025 09:39:40 -0800 Subject: [PATCH 16/53] Added a for-loop to print each element from the list --- src/ListPractice.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ListPractice.java b/src/ListPractice.java index 1dcb884..6314c43 100644 --- a/src/ListPractice.java +++ b/src/ListPractice.java @@ -25,7 +25,9 @@ public static void main(String[] args) { } // Iterate over the list using a traditional for-loop. // Print each index and value on a separate line - + for (int i = 0; i < stringList.size(); i++) { + System.out.println(stringList.get(i)); + } // Sort the list using the Collections library // Iterate over the list using a for-each loop From 518f05e8dec82b7bc086eb54f19377c1aa55e4f7 Mon Sep 17 00:00:00 2001 From: LauraV702 Date: Fri, 3 Jan 2025 09:41:15 -0800 Subject: [PATCH 17/53] Fixed for-loop to print each index and value on seperate line --- src/ListPractice.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ListPractice.java b/src/ListPractice.java index 6314c43..3cf7d62 100644 --- a/src/ListPractice.java +++ b/src/ListPractice.java @@ -26,7 +26,7 @@ public static void main(String[] args) { // Iterate over the list using a traditional for-loop. // Print each index and value on a separate line for (int i = 0; i < stringList.size(); i++) { - System.out.println(stringList.get(i)); + System.out.println(i + ": " + stringList.get(i)); } // Sort the list using the Collections library From add10b91ff31cead7746c0cf894293adc6979b0a Mon Sep 17 00:00:00 2001 From: LauraV702 Date: Fri, 3 Jan 2025 09:50:49 -0800 Subject: [PATCH 18/53] Added collection to sort stringList --- src/ListPractice.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ListPractice.java b/src/ListPractice.java index 3cf7d62..7a203a5 100644 --- a/src/ListPractice.java +++ b/src/ListPractice.java @@ -1,4 +1,6 @@ import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; public class ListPractice { @@ -29,7 +31,7 @@ public static void main(String[] args) { System.out.println(i + ": " + stringList.get(i)); } // Sort the list using the Collections library - + Collections.sort(stringList); // Iterate over the list using a for-each loop // Print each value on a second line From cd9d36effe7ec219aaae10de22068aa513929145 Mon Sep 17 00:00:00 2001 From: LauraV702 Date: Fri, 3 Jan 2025 09:55:16 -0800 Subject: [PATCH 19/53] Added a for-each loop and printed each on second line --- src/ListPractice.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ListPractice.java b/src/ListPractice.java index 7a203a5..073b2b7 100644 --- a/src/ListPractice.java +++ b/src/ListPractice.java @@ -34,7 +34,9 @@ public static void main(String[] args) { Collections.sort(stringList); // Iterate over the list using a for-each loop // Print each value on a second line - + for (String fruit : stringList) { + System.out.println(fruit); + } /* * Usage tip! * From 99eb7a5ca29096050f600c21022ed95f6aae0892 Mon Sep 17 00:00:00 2001 From: LauraV702 Date: Fri, 3 Jan 2025 09:57:42 -0800 Subject: [PATCH 20/53] Removed extra import and added space for better readability --- src/ListPractice.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/ListPractice.java b/src/ListPractice.java index 073b2b7..eb48ba2 100644 --- a/src/ListPractice.java +++ b/src/ListPractice.java @@ -1,5 +1,4 @@ import java.util.ArrayList; -import java.util.Collection; import java.util.Collections; public class ListPractice { @@ -8,35 +7,44 @@ public class ListPractice { public static void main(String[] args) { // Create an empty ArrayList of Strings and assign it to a variable of type List ArrayList stringList = new ArrayList<>(); + // Add 3 elements to the list (OK to do one-by-one) stringList.add("APPLE"); stringList.add("BANANA"); stringList.add("KIWI"); + // Print the element at index 1 System.out.println(stringList.get(1)); //output: BANANA + // Replace the element at index 1 with a new value // (Do not insert a new value. The length of the list should not change) stringList.set(1, "STRAWBERRY"); + // Insert a new element at index 0 (the length of the list will change) stringList.add(0, "ORANGE"); + // Check whether the list contains a certain string if (stringList.contains("AVOCADO")) { System.out.println("We have avocado :)"); } else { System.out.println("There is no avocado :("); } + // Iterate over the list using a traditional for-loop. // Print each index and value on a separate line for (int i = 0; i < stringList.size(); i++) { System.out.println(i + ": " + stringList.get(i)); } + // Sort the list using the Collections library Collections.sort(stringList); + // Iterate over the list using a for-each loop // Print each value on a second line for (String fruit : stringList) { System.out.println(fruit); } + /* * Usage tip! * From 296b2d6e5fb411e8603c75cf7b8b042cd751ded8 Mon Sep 17 00:00:00 2001 From: LauraV702 Date: Fri, 3 Jan 2025 09:59:51 -0800 Subject: [PATCH 21/53] Completed ListPractice --- src/ListPractice.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ListPractice.java b/src/ListPractice.java index eb48ba2..ea6d505 100644 --- a/src/ListPractice.java +++ b/src/ListPractice.java @@ -44,7 +44,7 @@ public static void main(String[] args) { for (String fruit : stringList) { System.out.println(fruit); } - + /* * Usage tip! * @@ -54,5 +54,7 @@ public static void main(String[] args) { * Otherwise, if you're iterating the in the conventional order and don't need the * index values a for-each loop is cleaner. */ + + //DONE } } \ No newline at end of file From 4abee5d05f6807f01cab7d313c52dfedefee067e Mon Sep 17 00:00:00 2001 From: LauraV702 Date: Fri, 3 Jan 2025 10:07:32 -0800 Subject: [PATCH 22/53] Created and added 3 different key and value pairs into mappy --- src/MapPractice.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/MapPractice.java b/src/MapPractice.java index 7ebfeac..cf5d94f 100644 --- a/src/MapPractice.java +++ b/src/MapPractice.java @@ -1,12 +1,15 @@ - +import java.util.HashMap; public class MapPractice { public static void main(String[] args) { // Create a HashMap with String keys and Integer values and // assign it to a variable of type Map - + HashMap mappy = new HashMap<>(); // Put 3 different key/value pairs in the Map // (it's OK to do this one-by-one) + mappy.put("a", 1); + mappy.put("b", 2); + mappy.put("c", 3); // Get the value associated with a given key in the Map From 9902325842416b2c387c73f9eaf713df15c260ac Mon Sep 17 00:00:00 2001 From: LauraV702 Date: Fri, 3 Jan 2025 10:12:48 -0800 Subject: [PATCH 23/53] Added for mappy to get the value with associated key and added size of the Map --- src/MapPractice.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/MapPractice.java b/src/MapPractice.java index cf5d94f..09783ea 100644 --- a/src/MapPractice.java +++ b/src/MapPractice.java @@ -12,9 +12,9 @@ public static void main(String[] args) { mappy.put("c", 3); // Get the value associated with a given key in the Map - + mappy.get("a"); // Find the size (number of key/value pairs) of the Map - + mappy.size(); // Replace the value associated with a given key (the size of the Map shoukld not change) // Check whether the Map contains a given key From 520b7cd1e6ccdcdb1e4227fda47f40636f26a966 Mon Sep 17 00:00:00 2001 From: LauraV702 Date: Fri, 3 Jan 2025 10:17:21 -0800 Subject: [PATCH 24/53] Added and replaced value and added if statements to check whether key exists --- src/MapPractice.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/MapPractice.java b/src/MapPractice.java index 09783ea..9b101cc 100644 --- a/src/MapPractice.java +++ b/src/MapPractice.java @@ -16,9 +16,13 @@ public static void main(String[] args) { // Find the size (number of key/value pairs) of the Map mappy.size(); // Replace the value associated with a given key (the size of the Map shoukld not change) - + mappy.replace("a", 0); // Check whether the Map contains a given key - + if (mappy.containsKey("d")) { + System.out.println("letter d is present within list MAPPY"); + } else { + System.out.println("There is no key present"); + } // Check whether the Map contains a given value // Iterate over the keys of the Map, printing each key From 3ed5a7340f5b4751bbb2a061ce845e2bc7749263 Mon Sep 17 00:00:00 2001 From: LauraV702 Date: Fri, 3 Jan 2025 10:20:51 -0800 Subject: [PATCH 25/53] Added if statements checking whether if value is present --- src/MapPractice.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/MapPractice.java b/src/MapPractice.java index 9b101cc..b73ad8a 100644 --- a/src/MapPractice.java +++ b/src/MapPractice.java @@ -19,12 +19,16 @@ public static void main(String[] args) { mappy.replace("a", 0); // Check whether the Map contains a given key if (mappy.containsKey("d")) { - System.out.println("letter d is present within list MAPPY"); + System.out.println("Letter d, is present within list MAPPY"); } else { System.out.println("There is no key present"); } // Check whether the Map contains a given value - + if (mappy.containsValue(2)) { + System.out.println("Value 2, is present within list MAPPY"); + } else { + System.out.println("There is no value present"); + } // Iterate over the keys of the Map, printing each key // Iterate over the values of the map, printing each value From b80f9ea0afcb6161a09ae5869c51438bd2b6bccf Mon Sep 17 00:00:00 2001 From: LauraV702 Date: Fri, 3 Jan 2025 10:28:48 -0800 Subject: [PATCH 26/53] Added loop to iterate over keys and values for MAPPY --- src/MapPractice.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/MapPractice.java b/src/MapPractice.java index b73ad8a..9410190 100644 --- a/src/MapPractice.java +++ b/src/MapPractice.java @@ -30,9 +30,13 @@ public static void main(String[] args) { System.out.println("There is no value present"); } // Iterate over the keys of the Map, printing each key - + for (String key : mappy.keySet()) { + System.out.println(key); + } // Iterate over the values of the map, printing each value - + for (Integer value : mappy.values()) { + System.out.println(value); + } // Iterate over the entries in the map, printing each key and value /* From f5475c7dbb67f0f38feab6cd0c68ffeaff4ed831 Mon Sep 17 00:00:00 2001 From: LauraV702 Date: Fri, 3 Jan 2025 10:41:34 -0800 Subject: [PATCH 27/53] Added for-each loop, printing each key and value --- src/MapPractice.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/MapPractice.java b/src/MapPractice.java index 9410190..b29b9e4 100644 --- a/src/MapPractice.java +++ b/src/MapPractice.java @@ -38,7 +38,10 @@ public static void main(String[] args) { System.out.println(value); } // Iterate over the entries in the map, printing each key and value - + for (HashMap.Entry entries : mappy.entrySet()) { + System.out.println("KEY " + entries.getKey()); + System.out.println("VALUE " + entries.getValue()); + } /* * Usage tip! * From abbfdcd94e792b1d5def5e49d37ec2cbcc99fb15 Mon Sep 17 00:00:00 2001 From: LauraV702 Date: Fri, 3 Jan 2025 10:42:51 -0800 Subject: [PATCH 28/53] Added space for better readability --- src/MapPractice.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/MapPractice.java b/src/MapPractice.java index b29b9e4..53b241b 100644 --- a/src/MapPractice.java +++ b/src/MapPractice.java @@ -4,6 +4,7 @@ public class MapPractice { public static void main(String[] args) { // Create a HashMap with String keys and Integer values and // assign it to a variable of type Map + HashMap mappy = new HashMap<>(); // Put 3 different key/value pairs in the Map // (it's OK to do this one-by-one) @@ -13,35 +14,43 @@ public static void main(String[] args) { // Get the value associated with a given key in the Map mappy.get("a"); + // Find the size (number of key/value pairs) of the Map mappy.size(); + // Replace the value associated with a given key (the size of the Map shoukld not change) mappy.replace("a", 0); + // Check whether the Map contains a given key if (mappy.containsKey("d")) { System.out.println("Letter d, is present within list MAPPY"); } else { System.out.println("There is no key present"); } + // Check whether the Map contains a given value if (mappy.containsValue(2)) { System.out.println("Value 2, is present within list MAPPY"); } else { System.out.println("There is no value present"); } + // Iterate over the keys of the Map, printing each key for (String key : mappy.keySet()) { System.out.println(key); } + // Iterate over the values of the map, printing each value for (Integer value : mappy.values()) { System.out.println(value); } + // Iterate over the entries in the map, printing each key and value for (HashMap.Entry entries : mappy.entrySet()) { System.out.println("KEY " + entries.getKey()); System.out.println("VALUE " + entries.getValue()); } + /* * Usage tip! * From 2e03a120f110d6047c7fc62c3aee0addd92ccb66 Mon Sep 17 00:00:00 2001 From: LauraV702 Date: Fri, 3 Jan 2025 10:43:31 -0800 Subject: [PATCH 29/53] Completed MapPractice --- src/MapPractice.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/MapPractice.java b/src/MapPractice.java index 53b241b..9222d4e 100644 --- a/src/MapPractice.java +++ b/src/MapPractice.java @@ -66,5 +66,7 @@ public static void main(String[] args) { * Example: If you want to hold the student ID numbers of everyone in a course, * and you don't care about any ordering. */ + + //DONE } } From d1b27ca03a79136ff53d419c77f44870bae0cec1 Mon Sep 17 00:00:00 2001 From: LauraV702 Date: Fri, 3 Jan 2025 10:46:40 -0800 Subject: [PATCH 30/53] Added ideas to refreshers --- toRefresh.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/toRefresh.md b/toRefresh.md index 163dcab..447e719 100644 --- a/toRefresh.md +++ b/toRefresh.md @@ -2,4 +2,6 @@ As you work through this exercise, write down anything that you needed to look up or struggled to remember here. It can be just a word or two (e.g. "joining strings"). You can use this as a guide of what to make extra sure you're refreshed on before exams and interviews. -- \ No newline at end of file +- ArrayList +- Map Entries +- Set vs. Map \ No newline at end of file From 1e7c0b424ac961e7f98faa846316a77330746fc4 Mon Sep 17 00:00:00 2001 From: LauraV702 Date: Fri, 3 Jan 2025 10:49:36 -0800 Subject: [PATCH 31/53] Added float to refresher --- toRefresh.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/toRefresh.md b/toRefresh.md index 447e719..d8494c2 100644 --- a/toRefresh.md +++ b/toRefresh.md @@ -4,4 +4,5 @@ As you work through this exercise, write down anything that you needed to look u - ArrayList - Map Entries -- Set vs. Map \ No newline at end of file +- Set vs. Map +- Float \ No newline at end of file From a9c1a98645c5a76910d6c8df6b6e6db9706ae775 Mon Sep 17 00:00:00 2001 From: LauraV702 Date: Fri, 3 Jan 2025 10:55:49 -0800 Subject: [PATCH 32/53] Addec and created a float with negative value, created an int with positive value, and ofound remainder of positiveVal --- src/NumberPractice.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/NumberPractice.java b/src/NumberPractice.java index bbec2fe..437300e 100644 --- a/src/NumberPractice.java +++ b/src/NumberPractice.java @@ -1,11 +1,11 @@ public class NumberPractice { public static void main(String args[]) { // Create a float with a negative value and assign it to a variable - + float negativeVal = -123f; // Create an int with a positive value and assign it to a variable - + int positiveVal = 123; // Use the modulo % operator to find the remainder when the int is divided by 3 - + int remainder = positiveVal % 3; // Use the modulo % operator to determine whether the number is even // (A number is even if it has a remainder of zero when divided by 2) // Use an if-else to print "Even" if the number is even and "Odd" From 5fef464069ff731a7c5a3b09fd625eb403cf3fc4 Mon Sep 17 00:00:00 2001 From: LauraV702 Date: Fri, 3 Jan 2025 11:00:50 -0800 Subject: [PATCH 33/53] Added if statement to determine whether number is even or odd --- src/NumberPractice.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/NumberPractice.java b/src/NumberPractice.java index 437300e..de443ad 100644 --- a/src/NumberPractice.java +++ b/src/NumberPractice.java @@ -10,7 +10,11 @@ public static void main(String args[]) { // (A number is even if it has a remainder of zero when divided by 2) // Use an if-else to print "Even" if the number is even and "Odd" // if the number is odd. - + if (positiveVal % 2 == 0) { + System.out.println("EVEN"); + } else { + System.out.println("ODD"); + } // Divide the number by another number using integer division /* From d8abcead5afd23e834a18c44a800c7b4ebeaa44a Mon Sep 17 00:00:00 2001 From: LauraV702 Date: Fri, 3 Jan 2025 11:02:45 -0800 Subject: [PATCH 34/53] Added division to the number --- src/NumberPractice.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/NumberPractice.java b/src/NumberPractice.java index de443ad..ddf18f8 100644 --- a/src/NumberPractice.java +++ b/src/NumberPractice.java @@ -16,7 +16,8 @@ public static void main(String args[]) { System.out.println("ODD"); } // Divide the number by another number using integer division - + int division = positiveVal / 3; + System.out.println(division); /* * Reminder! * From 1ac7783a01510e19547b95b5a15a80bd6742ae4a Mon Sep 17 00:00:00 2001 From: LauraV702 Date: Fri, 3 Jan 2025 11:03:21 -0800 Subject: [PATCH 35/53] Added space for better readability --- src/NumberPractice.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/NumberPractice.java b/src/NumberPractice.java index ddf18f8..716c499 100644 --- a/src/NumberPractice.java +++ b/src/NumberPractice.java @@ -2,10 +2,13 @@ public class NumberPractice { public static void main(String args[]) { // Create a float with a negative value and assign it to a variable float negativeVal = -123f; + // Create an int with a positive value and assign it to a variable int positiveVal = 123; + // Use the modulo % operator to find the remainder when the int is divided by 3 int remainder = positiveVal % 3; + // Use the modulo % operator to determine whether the number is even // (A number is even if it has a remainder of zero when divided by 2) // Use an if-else to print "Even" if the number is even and "Odd" @@ -15,9 +18,11 @@ public static void main(String args[]) { } else { System.out.println("ODD"); } + // Divide the number by another number using integer division int division = positiveVal / 3; System.out.println(division); + /* * Reminder! * From 1b4e7139f5061a568bda36898d2bcbda38692bde Mon Sep 17 00:00:00 2001 From: LauraV702 Date: Fri, 3 Jan 2025 11:03:53 -0800 Subject: [PATCH 36/53] Completed NumberPractice --- src/NumberPractice.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/NumberPractice.java b/src/NumberPractice.java index 716c499..0611474 100644 --- a/src/NumberPractice.java +++ b/src/NumberPractice.java @@ -22,7 +22,7 @@ public static void main(String args[]) { // Divide the number by another number using integer division int division = positiveVal / 3; System.out.println(division); - + /* * Reminder! * @@ -30,6 +30,6 @@ public static void main(String args[]) { * Example: * 7 / 3 = 2 when performing int division */ - + //DONE } } From 5f2d93d981a0ce6195c308717daa2d80772e5925 Mon Sep 17 00:00:00 2001 From: LauraV702 Date: Fri, 3 Jan 2025 11:13:26 -0800 Subject: [PATCH 37/53] Created and added elements to the HashSet --- src/SetPractice.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/SetPractice.java b/src/SetPractice.java index d2fc1c9..948c7fc 100644 --- a/src/SetPractice.java +++ b/src/SetPractice.java @@ -1,10 +1,15 @@ +import java.util.HashSet; + public class SetPractice { public static void main(String[] args) { // Create a HashSet of Strings and assign it to a variable of type Set + HashSet StringSet = new HashSet<>(); // Add 3 elements to the set // (It's OK to do it one-by-one) - + StringSet.add("TOMATO"); + StringSet.add("POTATO"); + StringSet.add("YAM"); // Check whether the Set contains a given String // Remove an element from the Set From f6a167c07f6ce6f3e2db161534775195f2c7211b Mon Sep 17 00:00:00 2001 From: LauraV702 Date: Fri, 3 Jan 2025 11:15:43 -0800 Subject: [PATCH 38/53] Added, checked, removed, and found the size of the Set within an Array --- src/SetPractice.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/SetPractice.java b/src/SetPractice.java index 948c7fc..825e3c5 100644 --- a/src/SetPractice.java +++ b/src/SetPractice.java @@ -10,12 +10,16 @@ public static void main(String[] args) { StringSet.add("TOMATO"); StringSet.add("POTATO"); StringSet.add("YAM"); + // Check whether the Set contains a given String + StringSet.contains("CABBAGE"); // Remove an element from the Set + StringSet.remove("TOMATO"); // Get the size of the Set - + StringSet.size(); + // Iterate over the elements of the Set, printing each one on a separate line /* From 51b87dc60de9c8014e8f004eb31a0661fbf14d54 Mon Sep 17 00:00:00 2001 From: LauraV702 Date: Fri, 3 Jan 2025 11:21:54 -0800 Subject: [PATCH 39/53] Added for each loop to iterate over each element --- src/SetPractice.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/SetPractice.java b/src/SetPractice.java index 825e3c5..fa30b0b 100644 --- a/src/SetPractice.java +++ b/src/SetPractice.java @@ -19,9 +19,12 @@ public static void main(String[] args) { // Get the size of the Set StringSet.size(); - - // Iterate over the elements of the Set, printing each one on a separate line + // Iterate over the elements of the Set, printing each one on a separate line + for (String veggie : StringSet) { + System.out.println(veggie); + } + /* * Warning! * From e1e0e6df41e667fea2519438f5166bb2b347f4b1 Mon Sep 17 00:00:00 2001 From: LauraV702 Date: Fri, 3 Jan 2025 11:22:40 -0800 Subject: [PATCH 40/53] Completed SetPractice --- src/SetPractice.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/SetPractice.java b/src/SetPractice.java index fa30b0b..2e8cfae 100644 --- a/src/SetPractice.java +++ b/src/SetPractice.java @@ -24,7 +24,7 @@ public static void main(String[] args) { for (String veggie : StringSet) { System.out.println(veggie); } - + /* * Warning! * @@ -37,5 +37,7 @@ public static void main(String[] args) { * * Also remember that sets do NOT have duplicates. */ + + //DONE } } From 55cd535585485c4d7a09076929e25d6377b1ca47 Mon Sep 17 00:00:00 2001 From: LauraV702 Date: Fri, 3 Jan 2025 11:37:18 -0800 Subject: [PATCH 41/53] Created a string, found the length, and concatenated them and printed result --- src/StringPractice.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/StringPractice.java b/src/StringPractice.java index 8d87617..38e2683 100644 --- a/src/StringPractice.java +++ b/src/StringPractice.java @@ -1,10 +1,17 @@ public class StringPractice { public static void main(String[] args) { // Create a string with at least 5 characters and assign it to a variable + String name = "Luigi"; + System.out.println(name); // Find the length of the string + System.out.println(name.length()); + System.out.println(); // Concatenate (add) two strings together and reassign the result + String nameTwo = "Mario "; + String result = nameTwo + name; + System.out.println(result); // Find the value of the character at index 3 From fd1b79ff75c1108e6b2511c8df60ecdf48bf42af Mon Sep 17 00:00:00 2001 From: LauraV702 Date: Fri, 3 Jan 2025 11:41:46 -0800 Subject: [PATCH 42/53] Added and founded value of name at index 3, and checked whether given substring exists within name --- src/StringPractice.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/StringPractice.java b/src/StringPractice.java index 38e2683..8451016 100644 --- a/src/StringPractice.java +++ b/src/StringPractice.java @@ -14,11 +14,15 @@ public static void main(String[] args) { System.out.println(result); // Find the value of the character at index 3 + System.out.println(name.charAt(3)); // Check whether the string contains a given substring (i.e. does the string have "abc" in it?) - + boolean substring = name.contains("abc"); + System.out.println(substring); + // Iterate over the characters of the string, printing each one on a separate line + // Create an ArrayList of Strings and assign it to a variable // Add multiple strings to the List (OK to do one-by-one) From a6232b969cafd39ad036497474b8e8bfd3e85208 Mon Sep 17 00:00:00 2001 From: LauraV702 Date: Fri, 3 Jan 2025 11:46:25 -0800 Subject: [PATCH 43/53] Iterated over characters of a string, name --- src/StringPractice.java | 6 ++++-- toRefresh.md | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/StringPractice.java b/src/StringPractice.java index 8451016..2c439ae 100644 --- a/src/StringPractice.java +++ b/src/StringPractice.java @@ -19,9 +19,11 @@ public static void main(String[] args) { // Check whether the string contains a given substring (i.e. does the string have "abc" in it?) boolean substring = name.contains("abc"); System.out.println(substring); - - // Iterate over the characters of the string, printing each one on a separate line + // Iterate over the characters of the string, printing each one on a separate line + for (char letter : name.toCharArray()) { + System.out.println(letter); + } // Create an ArrayList of Strings and assign it to a variable diff --git a/toRefresh.md b/toRefresh.md index d8494c2..d439fba 100644 --- a/toRefresh.md +++ b/toRefresh.md @@ -5,4 +5,5 @@ As you work through this exercise, write down anything that you needed to look u - ArrayList - Map Entries - Set vs. Map -- Float \ No newline at end of file +- Float +- .toCharArray() \ No newline at end of file From 967598ba2038a771d9ffa839c38360f247cb733a Mon Sep 17 00:00:00 2001 From: LauraV702 Date: Fri, 3 Jan 2025 11:55:22 -0800 Subject: [PATCH 44/53] Created ArrayList named Spiders, and added strings to Spiders --- src/StringPractice.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/StringPractice.java b/src/StringPractice.java index 2c439ae..aeaa3eb 100644 --- a/src/StringPractice.java +++ b/src/StringPractice.java @@ -1,3 +1,5 @@ +import java.util.ArrayList; + public class StringPractice { public static void main(String[] args) { // Create a string with at least 5 characters and assign it to a variable @@ -26,12 +28,17 @@ public static void main(String[] args) { } // Create an ArrayList of Strings and assign it to a variable - + ArrayList Spiders = new ArrayList<>(); // Add multiple strings to the List (OK to do one-by-one) + Spiders.add("Peter Parker"); + Spiders.add("Miguel O'Hara"); + Spiders.add("Miles Morales"); + Spiders.add("Gwen Stacy"); + Spiders.add("Peni Parker"); // Join all of the strings in the list together into a single string separated by commas // Use a built-in method to achieve this instead of using a loop - + // Check whether two strings are equal /* From ec661ab77e7d051c2ebaab751fe765746afb87f5 Mon Sep 17 00:00:00 2001 From: LauraV702 Date: Fri, 3 Jan 2025 11:56:58 -0800 Subject: [PATCH 45/53] Added SpiderPeople to join all the strings seperated by commas --- src/StringPractice.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/StringPractice.java b/src/StringPractice.java index aeaa3eb..d88b79f 100644 --- a/src/StringPractice.java +++ b/src/StringPractice.java @@ -38,7 +38,9 @@ public static void main(String[] args) { // Join all of the strings in the list together into a single string separated by commas // Use a built-in method to achieve this instead of using a loop - + String SpiderPeople = String.join(", ", Spiders); + System.out.println(SpiderPeople); + // Check whether two strings are equal /* From 55ded98fb4326e9ffb9d593b2723f816e0f98394 Mon Sep 17 00:00:00 2001 From: LauraV702 Date: Fri, 3 Jan 2025 12:01:02 -0800 Subject: [PATCH 46/53] Added if statements to check whether if two string are equal --- src/StringPractice.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/StringPractice.java b/src/StringPractice.java index d88b79f..bb3aa1a 100644 --- a/src/StringPractice.java +++ b/src/StringPractice.java @@ -42,6 +42,11 @@ public static void main(String[] args) { System.out.println(SpiderPeople); // Check whether two strings are equal + if (Spiders.get(3).equals(4)) { + System.out.println("Their names are equal!"); + } else { + System.out.println("Their names are not equal"); + } /* * Reminder! From 95364f560a9c439e67eda4c6bbde3d010d1f67ad Mon Sep 17 00:00:00 2001 From: LauraV702 Date: Fri, 3 Jan 2025 12:01:52 -0800 Subject: [PATCH 47/53] Completed StringPractice --- src/StringPractice.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/StringPractice.java b/src/StringPractice.java index bb3aa1a..5f9457c 100644 --- a/src/StringPractice.java +++ b/src/StringPractice.java @@ -55,5 +55,7 @@ public static void main(String[] args) { * * We use == when comparing primitives (e.g. int or char). */ + + //DONE } } From f7aff83f674aea80946be0292944630a44e132ba Mon Sep 17 00:00:00 2001 From: LauraV702 Date: Fri, 3 Jan 2025 12:07:20 -0800 Subject: [PATCH 48/53] Created and initialized person and age and created constructor --- src/Person.java | 8 ++++++-- toRefresh.md | 5 ++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Person.java b/src/Person.java index 8ab3f95..7a50f88 100644 --- a/src/Person.java +++ b/src/Person.java @@ -6,11 +6,15 @@ public class Person { // Declare a public String instance variable for the name of the person // Declare a private int instance variable for the age of the person - + public String name; + private int age; // Create a constructor that takes the name and age of the person // and assigns it to the instance variables - + public Person(String name, int age) { + this.name = name; + this.age = age; + } // Create a toString method that gives the name and age of the person diff --git a/toRefresh.md b/toRefresh.md index d439fba..4793832 100644 --- a/toRefresh.md +++ b/toRefresh.md @@ -6,4 +6,7 @@ As you work through this exercise, write down anything that you needed to look u - Map Entries - Set vs. Map - Float -- .toCharArray() \ No newline at end of file +- .toCharArray() + +- Public Private +- Constructor \ No newline at end of file From 54b66a8c9f9398feef2abc9f496631a9bc9bd89c Mon Sep 17 00:00:00 2001 From: LauraV702 Date: Fri, 3 Jan 2025 12:17:43 -0800 Subject: [PATCH 49/53] Created a toString --- src/Person.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Person.java b/src/Person.java index 7a50f88..9bc2835 100644 --- a/src/Person.java +++ b/src/Person.java @@ -17,7 +17,9 @@ public Person(String name, int age) { } // Create a toString method that gives the name and age of the person - + public String toString() { + return "Name: " + name + ", Age: " + age; + } // Implement the below public instance method "birthYear" // There should NOT be any print statement in this method. From 9f3f58ceb1fa3e18a11af07f4f31a471c7d065a3 Mon Sep 17 00:00:00 2001 From: LauraV702 Date: Fri, 3 Jan 2025 12:18:41 -0800 Subject: [PATCH 50/53] Created two instances person --- src/Person.java | 8 ++++++-- toRefresh.md | 4 +++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Person.java b/src/Person.java index 9bc2835..9a8c050 100644 --- a/src/Person.java +++ b/src/Person.java @@ -34,14 +34,18 @@ public String toString() { * @return The year the person was born */ // (create the instance method here) - + public int birthYear(int currentYear) { + return currentYear - age; + } public static void main(String[] args) { // Create an instance of Person + Person personOne = new Person("Caitlyn Kiramman",24); // Create another instance of Person with a different name and age and // assign it to a different variable - + Person personTwo = new Person("Mel Medarda", 33); + // Print the first person // Print the second person diff --git a/toRefresh.md b/toRefresh.md index 4793832..39d56f1 100644 --- a/toRefresh.md +++ b/toRefresh.md @@ -9,4 +9,6 @@ As you work through this exercise, write down anything that you needed to look u - .toCharArray() - Public Private -- Constructor \ No newline at end of file +- Constructor +- toString +- Instance \ No newline at end of file From ea78bc02781f7950eed2691e0ba3822231db3d92 Mon Sep 17 00:00:00 2001 From: LauraV702 Date: Fri, 3 Jan 2025 12:21:53 -0800 Subject: [PATCH 51/53] Printed both names, and made a local variable out of personOne --- src/Person.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Person.java b/src/Person.java index 9a8c050..b982fdf 100644 --- a/src/Person.java +++ b/src/Person.java @@ -40,22 +40,26 @@ public int birthYear(int currentYear) { public static void main(String[] args) { // Create an instance of Person - Person personOne = new Person("Caitlyn Kiramman",24); + Person personOne = new Person("Caitlyn Kiramman", 24); // Create another instance of Person with a different name and age and // assign it to a different variable Person personTwo = new Person("Mel Medarda", 33); // Print the first person + System.out.println(personOne); // Print the second person + System.out.println(personTwo); // Get the name of the first person and store it in a local variable + String ArcaneChara1 = personOne.name; // Using the birthYear method, get the birth year of the first person // and store it in a local variable. Input the actual current year (e.g. 2025) // as the argument. + // In a separate statement, print the local variable holding the birth year. /** From 6ec6b20c8f905b37026df3ceeeb7d401f13440aa Mon Sep 17 00:00:00 2001 From: LauraV702 Date: Fri, 3 Jan 2025 12:26:08 -0800 Subject: [PATCH 52/53] Called to the birthYear method for personOne and printed their birthYear --- src/Person.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Person.java b/src/Person.java index b982fdf..d92c22a 100644 --- a/src/Person.java +++ b/src/Person.java @@ -58,9 +58,11 @@ public static void main(String[] args) { // Using the birthYear method, get the birth year of the first person // and store it in a local variable. Input the actual current year (e.g. 2025) // as the argument. - + int currentYear = 2025; + int birthYear1 = personOne.birthYear(currentYear); // In a separate statement, print the local variable holding the birth year. + System.out.println(personOne.name + "Birth Year: " + birthYear1); /** * Terminology! From 9679e1cdf0db7ebab44d90f2f76a58041344db94 Mon Sep 17 00:00:00 2001 From: LauraV702 Date: Fri, 3 Jan 2025 12:28:36 -0800 Subject: [PATCH 53/53] Completed Person.java --- src/Person.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Person.java b/src/Person.java index d92c22a..0ede534 100644 --- a/src/Person.java +++ b/src/Person.java @@ -78,5 +78,7 @@ public static void main(String[] args) { * * Each instance has its own instance variables: Auberon's age can be different from Baya's age. */ + + //DONE } }