Class Battleship

Field summary, constructor summary, method summary, methods inherited from class java.lang.object, field details, constructor details, method details, getammunition, keepplaying.

  • The player has no more ammunition (a loss) Returns: true if the game should continue, false otherwise

printWelcome

apcsa assignment 8 battleship

# Unit 8: 2D Array

# lesson 1: 2-d arrays, # lesson 2: 2-d array algorithms, # assignment 8: battleship.

Unit 08 - 2D Array

Student Led Instruction.

Dec 6, 2022 • 1 min read

Make sure lesson has the following... Lesson Purpose and Objectives Review of Unit Materials and Videos from AP Classroom Key Vocabulary Key Coding requirements, by interactive coding challenges during lesson Highlight any Tricks or Gotchas from Unit, could be added to coding challenge Lesson should be interactive and hopefully fun 30 minutes of Homework / Hacks Lesson times is between 20 and 30 minutes

pep

Find what you need to study

Unit 8 Overview: 2D Array

5 min read • november 15, 2020

Athena_Codes

Athena_Codes

The Big Takeaway From this Unit

Unit overview.

Exam Weighting

7.5-10% of the test

Roughly 3 to 4 multiple-choice questions

Always FRQ #4 , which tests your ability to make, traverse, and create algorithms with a 2D array .

Enduring Understanding

In the past two units, you've learned how to store data in an array or an ArrayList . Now it's time to take it to another dimension with 2D arrays . You can either think of them as a grid or as a nested array , and we'll use both methods of thinking in this unit. Using these, we'll learn how to set these up and also how to traverse them.

Building Computational Thinking

For this unit, we will first learn how to create and initialize 2D arrays with various types of objects. These will be nested arrays. When traversing a list, you need to use nested arrays for loops, and these will need to have proper bounds to avoid an ArrayIndexOutOfBoundsException . If you can master 2D arrays , you can easily do 3D and higher-dimensional arrays if you ever decide to continue using Java after this course!

Main Ideas for This Unit

Initializing 2D Arrays

Representations of 2D Arrays

Traversing 2D Arrays

2D Array Algorithms

8.1: 2D Arrays

We can declare and initialize a 2D array in much the same form as a regular array , but with some subtle differences. However, there are still two ways to do so. We can initialize an empty 2D array that fills the array with the same "null"/initialized values as when we use the regular arrays from Unit 6 (also called 1D arrays ). However, this only works for "rectangular" arrays , where the two dimensions are clearly defined. We will talk more about this in the next subsection.

Here is how to do this:

/* Template: type[][] twoDArrayName = new type[firstDimension][secondDimension] */ int[][] arrayA = new int[3][4];

You can also initialize this with a pre-existing 2D array . This is similar to how you do 1D arrays.

Here is an example of an int[3][4] 2D array but with values pre-initialized:

int[][] arrayB = {{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}};

You don't have to use integers for the type stored in the array . You can use any other primitive or reference type! Integers are only used in this guide for simplicity.

Representing 2D Arrays

The 2D arrays can be represented in 2 major ways: one that is more visual, and one that is closer to how it is stored in the memory.

Memory Representation

The first way to think about this is how it is stored in memory, or in terms of data structures. A 2D array in this form is just a nested array . There is an outer array having arrays for its individual terms. In each inner array , the terms are objects or primitive type values of the type stated during initialization. When we initialize an array of type[firstDimension][secondDimension], we are actually initializing an array of length firstDimension (remember to use length instead of size as size is only for ArrayLists as in Unit 7). Each item in this array is another array containing secondDimension items of the specified type. For example, arrayA is an array with 3 items, each of which is an array with 4 integers.

A 2D array does not have to be rectangular. The inner arrays can vary in size. Here is an example of a non-rectangular array :

int[][] arrayC = {{1, 2}, {3}, {4, 5, 6}};

However, for the rest of this unit, we will be concerned with rectangular arrays, as those will be the type tested on the AP Exam.

Graphical Representation (only works for rectangular arrays)

For rectangular arrays, we can think of these as a grid , table, or matrix (if you have learned them in a prior math class). We can express arrayB from earlier as follows:

For a 2D array , type [firstDimension][secondDimension] . In this representation, firstDimension is the number of rows and secondDimension is the number of columns. Remember that arrayB is an example of an int[3][4] 2D array . Using the same logic, arrayB has 3 rows and 4 columns.

From this visual idea, we can easily find the indices to access an individual element of a 2D array .

Indices for Elements in an int[3][4] Array

For indices, we use 2 bracketed numbers, called double-index notation , with the first being the row and the second being the column. Remember that Java is a 0-indexed language , so the row indices range from [0, 1, 2, ..., firstDimension - 1] and the column indices range from [0, 1, 2, ..., firstDimension - 1] .

For a pre-initialized array , the number of rows is the length of the outer array , which is arrayName. length , while the number of columns is the length of each inner array , which for rectangular arrays is arrayName[0]. length .

With double-index notation , we can access any element of the array . However, if you use an index that is not in the allowed range, you get an ArrayIndexOutOfBoundsException . For example, for arrayB, saying arrayB[2][3] means that we want the element in the third row and the fourth column, which corresponds to 12. Lets do a little practice using arrayB from above:

What are the indices for the following: 1. 6 2. 4 3. 9 4. 5 What values are given for the following indices: 5. [1][3] 6. [0][2] 7. [3][2] 8. [2][0]

1. [1][1] (2nd row, 2nd column) 2. [0][3] (1st row, 4th column) 3. [2][0] (3rd row, 1st column) 4. [1][0] (2nd row, 1st column) 5. 8 (2nd row, 4th column) 6. 3 (1st row, 3rd column) 7. The last row in the array has row index 2, since there is no fourth row with index 3, an ArrayIndexOutOfBoundsException is thrown 8. 9 (3rd row, 1st column)

We will use the graphical representation of 2D arrays in the rest of this unit as it is easier to visualize and understand.

Key Terms to Review ( 29 )

0-indexed language

ArrayIndexOutOfBoundsException

Double-index notation

Graphical Representation

Initialize 2D Arrays

Inner Array

Key Term: Practice with Indices and Values

Multiple-choice Questions

Nested Array

Nested For Loops

Non-rectangular Array

Outer Array

Primitive Type Values

Fiveable

About Fiveable

Code of Conduct

Terms of Use

Privacy Policy

CCPA Privacy Policy

AP Score Calculators

Study Guides

Practice Quizzes

Cram Events

Crisis Text Line

Help Center

Stay Connected

© 2024 Fiveable Inc. All rights reserved.

AP® and SAT® are trademarks registered by the College Board, which is not affiliated with, and does not endorse this website.

Navigation Menu

Search code, repositories, users, issues, pull requests..., provide feedback.

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly.

To see all available qualifiers, see our documentation .

  • Notifications You must be signed in to change notification settings

Answers for all units of the APCS CodeHS course.

ivan-edu/apcsa-codehs

Folders and files, repository files navigation, ap computer science a - codehs.

This repository contains all the answers for units 1 - 10 in the APCSA CodeHS Java course. Be sure to leave a star 🌟

  • Instagram: @31Carlton7

Common Answers

If an assignment has 2 or more files....

If an assignment has 2 or more files required, the individual file will be denoted as such:

If an assignment has a prefix of M- ...

If an assignment has a prefix of M- it's an actual school project, not a CodeHS assignment and can be ignored.

It is recommended that you attempt to solve the problems by yourself before using the work provided here so you can learn from your mistakes. Try to use this only to review/compare your own work, or if you are very stuck on a problem.

Completed Units

  • Add Unit 1 (Primitive Types)
  • Add Unit 2 (Using Objects)
  • Add Unit 3 (Boolean Expressions and IF Statements)
  • Add Unit 4 (Iteration)
  • Add Unit 5 (Writing Classes)
  • Add Unit 6 (Array)
  • Add Unit 7 (ArrayList)
  • Add Unit 8 (2D Array)
  • Add Unit 9 (Inheritance)
  • Add Unit 10 (Recursion)

If you have any questions, you can reach me here:

AP Computer Science A

Assignments by date.

This is where each week's assignments in AP CS A are posted. Please let me know if you have any questions!

Week 3 6 : Monday, May 13 th – Friday, May 1 7 th

Seniors, i t was a pleasure having you in class this year! Good luck with all of your future endeavors, CONGRATULATIONS, and please keep in touch!

Week 3 5 : Monday, May 6 th – Friday, May 10th

This is it! The AP C omputer Science A exam is on Wednesday, May 8th at 12pm . Make sure you look over the practice materials I've given you, and you may also want to review the past quizzes and exams in ProjectSTEM. Let me know if you have any questions, and good luck!!

Week 34: Monday, April 29th – Friday, May 3rd

We've finally made it to May! This week is more of the same – study for the AP e xam on We dnesday, May 8th at 12pm .

Also, d on't forget that Friday, May 3rd is the #RHSE3 Celebration – seniors, wear your Employment, Enlistment or Enrollment gear!

Have a great week, and please let me know if you have any questions.

Week 33: Monday, April 22nd – Friday, April 26th

Welcome to the last full week of April! We're almost done with state testing, so please make note of our last day of the late arrival schedule on Monday. We're going to continue preparing for the AP exam , so m ake sure you finish those practice FRQs and multiple choice exams.

Have a great week! Hang in there – we're almost done.

Week 32: Monday, April 15th – Friday, April 19th

Welcome to another wacky week at Roosevelt High School! This week, you'll have a "late arrival" schedule due to state testing:

apcsa assignment 8 battleship

Same plan as last week - keep prepping for the AP exam. I hope you're able to sleep in this week! As always, please let me know if you have any questions.

Week 31: Tuesday, April 9th – Friday, April 12th

Hello again! I hope you survived the solar eclipse and enjoyed your bonus 3-day weekend. Here's what we're doing for this week as we wrap up the last topic in the course:

finish Unit 10 Exam 🥨 

work on practice exams and FRQs

Now that we've finished all of the material in the AP Computer Science A course, we can focus on getting you ready for the exam in May! My goal is to provide you with class time to study and work on practice questions so that you don't have to do any of that at home. Congrats on making it through to the end! Let me know if you have any questions.

Week 30 : Tuesday , April 2nd – Friday, April 5th

Welcome back! I hope you had a fun and relaxing Spring Break and are fully recharged and ready to prepare for the AP Exam in May. Here's what we're doing for the first week of April as we continue our work in Unit 10: Recursion :

Unit 10: Lesson 3 - Binary Search

Unit 10: Lesson 4 - Merge Sort

On Monday, April 8th, the Great American Eclipse will take place as a rare total solar eclipse goes across North America, including most of Ohio. Here's some useful information about the timing of the eclipse :

1:59:28 pm: Partial eclipse begins - the moment the edge of the Moon touches the edge of the Sun is called "first contact"

3:14:30 pm: Totality begins 😱 - the moment the edge of the Moon covers all of the Sun is called "second contact"

3:15:54 pm: Maximum eclipse‼️ - this is the deepest point of the eclipse, with the Sun at its most hidden

3:17:17 pm: Totality ends 😭 - the moment the edge of the Moon exposes the Sun is called "third contact"

4:29:17 pm: Partial eclipse ends - the moment the edge of the Moon leaves the edge of the Sun is called "fourth contact"

There's also a really cool interactive map of the eclipse path , and you can find out all about the many, many eclipse-related events happening this weekend in Kent at the Kent Total Eclipse 2024 website . Make sure to build a pinhole projector out of cardboard and aluminum foil ahead of time – they're really cool and easy to make!

I hope you have a great week back from Spring Break! As always, please let me know if you have any questions.

Week 29: Monday, March 18th – Friday, March 22nd

We've made it to Spring Break! 4th Quarter has begun and we can start Unit 10: Recursion – our last unit! Here's what we're doing for the first week of Spring:

BEGIN 4th QUARTER

start Unit 10: Recursion

Unit 10: Lesson 1 - Intro to Recursion

Unit 10: Lesson 2 - Recursive Functions With Returns

Unit 10 Quiz

I hope you have an awesome Spring Break and get lots of rest and relaxation ! I'll see you next month. 😎

Week 28: Monday, March 11th – Friday, March 15th

Welcome to the end of 3rd Quarter! I hope you survived the time change over the weekend and you're ready to finish strong. Here's what we're doing for this last week of Winter as we wrap up Unit 9: Inheritance :

Assignment 9: Ultimate Frisbee

Unit 9 Exam 🎏

E N D OF 3rd QUARTER

Seniors, you're 15/16ths done with high school. 😱 I hope you have a great week, and please let me know if you have any questions!

Week 2 7 : Monday, March 4 th – Friday, March 8th

Here's the plan for this week as we get further into Unit 9: Inheritance :

Unit 9: Lesson 2 - Inheritance Overriding Methods

Unit 9 Quiz 🚐

Unit 9: Lesson 3 - Is-a and Has-a Relationships

We only have two weeks left in 3rd Quarter, so make sure you're getting all of your work completed and turned in. Let me know if you have any questions, and have a wonderful week!

Week 2 6 : Monday , February 2 6 th – Friday, March 1st

Welcome to the end of February! To wrap up Black History Month, I'd like to tell you about John Henry Thompson (b. 1959), the creator of the influential Lingo programming language. The son of Jamaican immigrants, Mr. Thompson got his first opportunity to work with a computer as a 10th grader at the Bronx High School of Science when his geometry teacher, Ms. Strauss, gave him early access to the math department's computer lab and helped him get his first job as a computer operator in the New York State Psychiatric Institute. After graduation, he earned his Bachelor's degree in Computer Science and Visual Studies from MIT in 1983 and continued on as a technical instructor, developed an early color pre-press design system for the Visible Language Workshop, which is now part of the MIT Media Lab. Mr. Thompson then became a project lead at Lucasfilm on the EditDroid project, an early nonlinear editing system that was a precursor to Final Cut, the industry standard in video editing. In 1987 he joined Macromedia (now part of Adobe), where he contributed to the development of a number of products, including Macromedia Director, and he invented the Lingo programming language and XObjects, which made it easier to create interactive multimedia content like Flash, Shockwave and graphics-based CD-ROMs. If you've ever played an interactive game in a web browser, his work helped make that possible! For the past two decades, Mr. Thompson has continued teaching in New York City, Philadelphia, Jamaica, and online, and he has since become an outspoken critic of social media companies such as Facebook for how they use personal data and what he describes as their negative impacts on society.

Here's the plan for this week as we wrap up 2D arrays and move into Unit 9: Inheritance :

Assignment 8: Battleship

Unit 8 Exam 🍝

start Unit 9: Inheritance

Unit 9: Lesson 1 - Inheritance

Remember, no school for Seniors on Tuesday due to the ACT. As always, please let me know if you have any questions. Have a great week!

Week 2 5 : Tuesday , February 20 th – Friday , February 23rd

Hello again! This week I'd like to tell you about Dr. Clarence "Skip" Ellis (1943-2014), the first Black person to earn a PhD in computer science. Dr. Ellis grew up in Chicago and graduated from Parker High School while also working as a part-time night shift security guard for the Dover Corporation. While at Dover, he watched over the company's mainframe computers and became fascinated by them, so he read over the manuals during his shift and learned how to operate and repair the vacuum-tube-based machines. He earned degrees in mathematics and physics from Beloit College in Wisconsin, and while at Beloit, he was one of 10 North American college students to attend a computer science program at the University of Illinois, Urbana-Champaign. Based on his experiences there, he earned his PhD in computer science from Urbana-Champaign in 1969, making him the first Black person to ever do so. Dr. Ellis worked at Bell Labs, IBM, and Xerox, and from 1976–1984, he worked at the Palo Alto Research Center, where he led the team that created Officetalk, the first program to use icons and the Internet to allow for long-distance collaboration. This means that every icon-based app or operating system you've ever used was directly influenced by Skip Ellis. You could say he's "iconic"! (Sorry.)

Here's the plan for this week as we begin Unit 8 : 2 D Array :

start Unit 8: 2D Array

Unit 8: Lesson 1 - 2-D Array

Unit 8: Lesson 2 - 2-D Array Algorithms

Two-dimensional (2D) arrays can be pretty challenging, so we're going to take this topic slowly and use some graphical organizers to make sure you understand what's going. If you think of a 2D array as a grid, like a chessboard, then they're a lot easier to visualize, which should make it a little easier to figure out how to implement them. Enjoy your abbreviated week, and as always, please let me know if you have any questions!

Week 2 4 : Monday, February 12 th – Thursday , February 15 th

Hello again! This week I'd like to tell you about Dr. Timnit Gebru , a Black computer scientist who studies artificial intelligence (AI), algorithmic bias and data mining. Dr. Gebru was born in Ethiopia and fled the Eritrean–Ethiopian War when she was 15, eventually receiving political asylum in the Unites States. She earned her bachelor's and master's degrees as well as her PhD from Stanford University. While at Stanford, she worked as an intern at Apple making audio circuitry and later developed signal processing algorithms for the first iPad. After brief stint at Microsoft where she investigated racial bias in facial recognition software, she joined Google in 2018 to co-lead a team the ethics of artificial intelligence. However, in late 2020, her employment at Google was terminated when she refused to withdraw a research paper about the serious risks of large language model AI systems (Dr. Gebru claims that she was fired, while Google has refused to say whether she resigned or was terminated). Since leaving Google, Dr. Gebru has co-founded Black in AI, a community of Black researchers working in AI, and the Distributed Artificial Intelligence Research Institute (DAIR), a "space for independent, community-rooted AI research, free from Big Tech's pervasive influence". She has earned numerous accolades, including being named one of the world's 50 greatest leaders by Fortune Magazine in 2021 and one of Time Magazine's most influential people of 2022.

Here's the plan for this week as we wrap up Unit 7: ArrayList :

Assignment 7: Game Wheel

Unit 7: Review

Unit 7 Exam  

Enjoy your looong weekend, and please let me know if you have any questions!

Week 2 3 : Monday, February 5 th – Friday, February 9th

Happy Black History Month! Before I list this week's activities, I'd like to tell you about Dorothy J. Vaughan (1910–2008), the first African-American female supervisor of the National Advisory Committee for Aeronautics (NACA) who became an expert in digital computers and their applications in NASA programs. Ms. Vaughan graduated from Wilberforce University in Ohio with a degree in mathematics and started out as a math teacher. In 1943, to support our country's efforts in World War II, she joined NACA as a human "computer" who did complex calculations for engineers and scientists. She worked with computers Vera Huckel and Sara Bullock to create an algebraic methods handbook for mechanical calculating machines, and when NACA became NASA, she joined its new Analysis and Computation Division and became an expert FORTRAN programmer. Ms. Vaughan and her countless calculations supported NACA and NASA accomplishments and helped to achieve our country’s aerospace goals. Very impressive!

Here's the plan for this week as we continue Unit 7: ArrayList :

Unit 7: Lesson 3 - Array Algorithms with ArrayLists

Unit 7 Quiz 🎈

Unit 7: Lesson 4 - Linear Search

Unit 7: Lesson 5 - Selection Sort

Unit 7: Lesson 6 - Insertion Sort

This is our last full week of school for a while, because next week we'll only have three and a half school days before having a four-and-a-half day weekend, and then we'll have other interruptions like the ACT. I hope you have a great week, and as always, let me know if you have any questions!

Week 22: Monday, January 29th – Friday, February 2nd

Welcome to the end of January! This month has really flown by, although I'm sure that having Winter Break, MLK Jr. Day and three calamity days all helped with that. Here's the plan for this week as we start Unit 7: ArrayList :

finish Assignment 6: Array Statistics

Unit 6 Exam 👟

start Unit 7: ArrayList

Unit 7: Lesson 1 - ArrayList

Unit 7: Lesson 2 - Traversing ArrayLists

With any luck, we'll be able to get through a full week without any interruptions as we move into February and one month closer to the end of the school year. Please let me know if you have any questions!

Week 2 1 : Mon day, January 22nd – Friday, January 26th

Hello again! Last week was certainly an interesting series of events. I hope you took advantage of your bonus three-day weekend and got some rest and relaxation! W e're going to continue our work on Unit 6: Array this week :

finish Unit 6: Lesson 4 - Algorithms on Arrays

Unit 6: Lesson 5 - The Enhanced For Loop

Assignment 6: Array Statistics

The weather this week looks to be much warmer and rainy, so I'm hoping we'll be able to get through all five days without any interruptions. Next week, we'll take the Unit 6 Exam and move on to Unit 7: ArrayList . Have a great week, and let me know if you have any questions!

Week 20: Tuesday, January 16th – Friday, January 19th

I hope you enjoyed your three day weekend! This week, we're going to continue our work on Unit 6: Array . Here's the plan:

Unit 6 Quiz

Unit 6: Lesson 4 - Algorithms on Arrays

These topics should be pretty straightforward, but a s always, please let me know if you have any questions . Have a great week!

Week 19: Monday, January 8th – Friday, January 12th

Happy New Year, and welcome back from Winter Break! I hope you were able to take some time to rest, relax and recharge before we get right back into the thick of things. Here's the plan for our first school week of 2024 as we start our work on Unit 6: Array :

review 1st Semester Exam

start Unit 6: Array

Unit 6: Lesson 1 - One-Dimensional Arrays

Unit 6: Lesson 2 - Traversing an Array

Unit 6: Lesson 3 - Arrays of Strings

I hope you have a great first week back! Let me know if you have any questions.

Week 18: Monday, December 18th – Friday, December 22nd

We finally made it to the end of 1st Semester! Your exam will be on Thursday, December 20th at 7:30am in Room 211, so make sure you're there on time. T he 1st Semester Exam will be on paper and will include 40 multiple choice questions from all five units so far. It'll look a lot like your quizzes, tests and the practice exam I gave you in class, so review those materials to prepare . Here's the schedule for the week:

1st Semester Exam prep

HW: work on 1st Semester Practice Exam

1st, 2nd & 6/7 or 7/8th period exams

HW: finish 1st Semester Practice Exam

Thu . 12/21

1st Semester Exam @7:30–9:00am

ALL WORK DUE FOR 1st SEMESTER

In case you didn't get it last week, the entire exam schedule is available here . I hope all of your exams go smoothly and you have a restful Winter Break. Have a Happy New Year, and I'll see you in 2024!

Week 1 7 : Monday, December 11 th – Friday, December 15 th

Welcome back! Here's the plan for the last full week of 1st Semester as we wrap up Unit 5: Writing Classes :

Assignment 5: Player

Unit 5: Review

Unit 5 Exam 🦒 (please complete by Tuesday 12/19)

Your 1st Semester Exam will be on Thursday, December 21st at 7:30am and covers Units 1- 5 of the course with 40 multiple choice questions that you'll take on paper . I've prepared a practice exam that is very similar to your semester exam that I'll give you in class . The entire exam schedule is available here . I strongly recommend taking notes while doing the practice exam and doing it as far in advance as possible so that you can ask me questions if you need help with anything. Have a great week!

Week 16: Monday, December 4th – Friday, December 8th

Hello again! We're going to continue our work on Unit 5: Writing Classes so we have all the tools we need to complete Assignment 5 next week. Here's the plan for the first full week of December:

finish Unit 5: Lesson 6 - Constructors

Unit 5: Lesson 7 - Documenting a class

Unit 5: Lesson 8 - Static Vs. Instance

Unit 5: Lesson 9 - Wider Impacts of Computing

Next week, after we complete Assignment 5 you'll have time to complete the practice exam and study for the 1st Semester Exam, which is all multiple choice and should be very similar to the quizzes and exams you've seen so far . As always, let me know if you have any questions. Have a wonderful week!

Week 15: Monday, November 27th – Friday, December 1st

Welcome back from Thanksgiving Break! I hope you were able to rest , recharge and get caught up (if n ecessary) so we can make it through the next four weeks before we go on Winter Break. Here's the plan for the last week of November:

finish Unit 5: Lesson 4 - Return Methods

Unit 5 Quiz 🥪

Unit 5: Lesson 5 - Classes - The Basics

Unit 5: Lesson 6 - Constructors

I hope your first week back goes well! As always, let me know if you have any questions.

PS: Make sure you plug in your Chromebook to charge overnight!

Week 1 4 : Monday, November 13 th – Friday, November 1 7 th

We finally made it to Thanksgiving Break! 🦃 Here's the plan as we continue our work on Unit 5: Writing Classes : 

Unit 5: Lesson 2 - Parameters

Unit 5: Lesson 3 - Parameters - Primitive vs. Class 

Unit 5: Lesson 4 - Return Methods

I hope you get some rest and relaxation over break! Use this time to get caught up if you need to, and please let me know if you have any questions about anything you're working on.

Week 1 3 : Monday, November 6 th – Friday, November 10th

Hello again! Here's the plan for the first full week of November as we wrap up Unit 4: Iteration and move on to Unit 5: Writing Classes : 

finish Assignment 4: String Shortener

Unit 4: Review

Unit 4 Exam 🪥

start Unit 5: Writing Classes

Unit 5: Lesson 1 - Void Methods

L et me know if you have any questions , and have a great week!

Week 12: Monday, October 30th – Friday, November 3rd

It's the last week of October, and it's finally starting to feel like Fall ! 🎃 I hope you got out and enjoyed the last bits of nice weather. Here's the plan for this week as we continue our work in Unit 4 : Iteration :

Unit 4: Lesson 4 - Algorithms for Strings

Unit 4 Quiz 🐧

Unit 4: Lesson 5 - Nested loops

Unit 4: Lesson 6 - Algorithm Efficiency

start Assignment 4: String Shortener

As always, please let me know if you have any questions. Stay warm!

Week 11 : Monday, October 23rd – Friday, October 2 7 th

Welcome to 2nd Quarter! According to the Project STEM pacing guide, here's where we should be as we start Week 11 with Unit 4: Iteration :

BEGIN 2nd QUARTER

start Unit 4: Iteration

Unit 4: Lesson 1 - While Loops

Unit 4: Lesson 1 ½ - Tracing Code

Tuesday 10/24: Security Summit Field Trip to I-X Center (meet at the cafeteria entrance at 8:45am!)

Wednesday 10/25: Capture the Flag Competition! (in class)

Unit 4: Lesson 2 - Algorithms for Numbers

Unit 4: Lesson 3 - The For Loop

These coding activities should be a little quicker to finish, but as always, please let me know if you have any questions. Have a great week, and get out and enjoy the nice weather while it lasts!

Week 10 : Monday, October 16 th – Friday , October 20th

Welcome back from your 3-day weekend! Here's what we're doing for the last week of 1st Quarter as we wrap up Unit 3:

Unit 3: Lesson 7 - Comparing Objects

Assignment 3 - Crack the Code!

Unit 3: Review

Unit 3 Exam 🐘

END OF 1st QUARTER

Let me know if you have any questions. Have a great week!

Week 9: Monday, October 9th – Thursday, October 12th

I hope you had a great weekend! This week, we'll continue our work on Unit 3: Boolean Expressions and If Statements. Here's the plan for this abbreviated week:

Unit 3: Lesson 4 - Logical Operators and Truth Tables

Unit 3: Lesson 5 - Short Circuit Evaluation

Unit 3: Lesson 6 - De Morgan's Law

We'll also have these important events this week:

Monday 10/9: Parent-Teacher Conferences @5-8pm –  sign up here ! Tuesday 10/10: Passport to IT Careers field trip (8:15am-2:00pm) Thursday 10/12: Early Release Day Friday 10/13: Teacher PD Day –  NO SCHOOL

Enjoy your three-and-a-half-day weekend! Please let me know if you have any questions.

Week 8 : Monday, October 2nd – Friday, October 6 th

Welcome to the first week of October!  Here's the plan for this week as we move int o a new unit :

start Unit 3: Boolean Expressions and If Statements

Unit 3: Lesson 1 - Simple Ifs

Unit 3: Lesson 2 - Relational Operators

Unit 3: Lesson 3 - Else

Unit 3 Quiz

Boolean expressions and if statements are absolutely critical concepts in computer science. Some experts have argued that artificial intelligence (AI) is nothing more than lots and lots of if statements, so we'll want to make sure we have a solid understanding of these topics. I hope you have a great week! As always, p lease let me know if you have any questions.

Week 7 : Monday, September 25 th – Friday, September 2 9th

Hi there ! We're going to wrap up Unit 2: Using Objects with an assignment that looks harder than it actually is, and then we'll take the Unit 2 Exam. Here's the plan for the first week of autumn 🍂:

Unit 2: Review

Assignment 2: Control Tower

Unit 2 Exam ⛵️

I hope you have a great week! Please let me know if you have any questions.

Week 6 : Monday, September 1 8 th – Friday, September 22nd

Hello again! For this final week of summer , we're going to continue our unit on objects in Java with important but less confusing topics . Here 's the plan:

Unit 2: Lesson 6 - Using methods

Unit 2: Lesson 7 - Wrapper Classes

Unit 2: Lesson 8 - Math Functions

Methods are simply functions that somehow interact with or modify an object, while wrapper classes let us use methods with our primitive data types (like integers and floats). Easy stuff, I promise! As always, please let me know if you have any questions.

Week 5: Monday, September 11th – Friday, September 15th

Welcome back! I hope you had a great Homecoming weekend. This week, we' re going to continue learning about objects in Java . Here are the topics we'll be working on:

finish Unit 2: Lesson 3 - String Methods

Unit 2: Lesson 4 - Classes and Objects

Unit 2 Quiz 🍍

Unit 2: Lesson 5 - Using Constructors

You've already been using classes like String and Scanner, so we're just going to dive a little deeper into their structure, which is defined by a constructor . It sounds a little w eird, but with enough examples and analogies, I'm confident you'll understand it, and that knowledge is going to be extremely helpful going forward. Let me know if you have any questions, and have a great week!

Week 4: Tuesday, September 5th – Friday, September 8th

I hope you enjoyed your 3-day weekend! We're wrapping up Unit 1 this week and moving on to Unit 2: Using Objects . Here's the plan for this hot, hot week:

Unit 1 Exam

start Unit 2: Using Objects

Unit 2: Lesson 1 - Strings and Class Types

Unit 2: Lesson 2 - Escape Sequences and String Concatenation

start Unit 2: Lesson 3 - String Methods

As always, please let me know if you have any questions or need help with anything at all. Stay cool!

Week 3 : Monday, August 28th – Friday, September 1st

I hope you enjoyed your unexpected 3-day weekend! Here's what we're doing in class for the last week of August:

Unit 1: Lesson 5 - Modular Division

Unit 1: Lesson 6 - Numeric Casts

Assignment 1: Calculating Grades

Unit 1: Review

The assignments in this course can sometimes be a little challenging, so please ask me for help as you're working on Assignment 1. We'll take the Unit 1 Exam next week after another 3-day weekend. Keep up the great work, and as always, let me know if you have any questions!

Week 2: Monday, August 21st – Friday, August 25th

Welcome to the first full week of the 2023-2024 school year! Now that we've had a few days to get to know each other and get everyone logged in to ProjectSTEM , we can get to work! Here's what we're doing in class this week:

Unit 1: Lesson 1 - Output In Java

Unit 1: Lesson 2 - User Input and Variables

Unit 1: Lesson 3 - Data Types

Unit 1 Quiz

Unit 1: Lesson 4 - Number Calculations

I've also included a link to a weekly schedule of all of the assignments for the year .

I hope you had a great first week and that you were able to get some rest this weekend before we attempt to go to school for five full days without strange bell schedules or burning birds. Let me know you have any questions!

New Sandbox Program

Click on one of our programs below to get started coding in the sandbox!

apcsa assignment 8 battleship

  • What is CodeHS?
  • Course Catalog
  • 6-12 Curriculum Pathway
  • All Courses
  • Hour of Code
  • Assignments
  • Classroom Management
  • Progress Tracking
  • Lesson Plans
  • Offline Handouts
  • Problem Guides
  • Problem Bank
  • Playlist Bank
  • Quiz Scores
  • Integrations
  • Google Classroom
  • Brightspace (D2L)
  • Professional Development
  • In-Person PD
  • Virtual PD Workshops
  • Certification Prep
  • Free PD Workshops
  • Testimonials
  • K-12 Framework
  • Common Core Math
  • State Standards
  • Scope and Sequence
  • Connecticut
  • Massachusetts
  • Mississippi
  • New Hampshire
  • North Carolina
  • North Dakota
  • Pennsylvania
  • Rhode Island
  • South Carolina
  • South Dakota
  • West Virginia
  • Bring to My School
  • Homeschools
  • Individual Learners

apcsa assignment 8 battleship

Sign up for a free teacher account to get access to curriculum, teacher tools and teacher resources.

Sign up as a student if you are in a school and have a class code given to you by your teacher.

Interested in teaching with CodeHS? Get in touch, so we can help you bring CodeHS to your school!

IMAGES

  1. Assignment 8: Battleship Instructions In this

    apcsa assignment 8 battleship

  2. Assignment 8: Battleship Instructions In this

    apcsa assignment 8 battleship

  3. Assignment 8: Battleship Instructions In this

    apcsa assignment 8 battleship

  4. Assignment 8: Battleship Instructions In this

    apcsa assignment 8 battleship

  5. Assignment 8: Battleship Instructions In this

    apcsa assignment 8 battleship

  6. GitHub

    apcsa assignment 8 battleship

VIDEO

  1. Peter Singer Animal Rights

  2. Eres lo que Siembras #eresloquesiembras #manifestación #prosperidad #leydeatracción #manifestar #lda

  3. Changer robinet d'un lave-mains

  4. World of Warships

  5. World of Warships #272

  6. hells 8 (battleship)

COMMENTS

  1. Assignment 8: Battleship : r/EdhesiveHelp

    Instructions. In this assignment, you will create a simple class for playing the game battleship. Battleship is played on a square grid of 10 rows and 10 columns, which you will represent using a 2-D array in a class named Board. A separate class, Battleship, will allow you to try playing your game and see whether the methods work as planned.

  2. Does anyone have the unit 8 battleship assignment?

    3.6K subscribers in the EdhesiveHelp community. Need answers for a code practice? We got you! If you need answer for a test, assignment, quiz or….

  3. Jovakan/apcsa2020: Answer key for APCSA Edhesive 2020

    Answer key for APCSA Edhesive 2020 - learn from example, don't plagiarize. - Jovakan/apcsa2020. ... Lessons 1-8. Assignment 2: Control Tower. Unit 3: Boolean Expressions and If Statements. Lessons 1-7. ... Assignment 8: Battleship. Lab: Steganography. Unit 9: Inheritance. Lessons 1-3. Assignment 9: Ultimate Frisbee.

  4. Unit 8 Assignment 8 : r/EdhesiveHelp

    Unit 8 Assignment 8 . Java Does anyone have the code for the Java assignment 8 battleship? I would really appreciate it public class Board{ private String[][] squares; public Board(){ } public String toString(){ return ""; } public boolean addShip(int row, int col, int len, boolean horizontal){ ...

  5. Assignment 8: Battleship Instructions In this

    When a player chooses a square containing a ship, that square is. Assignment 8: Battleship Instructions In this assignment, you will create a simple class for playing the game battleship. Battleship is played on a square grid of 10 rows and 10 columns, which you will represent using a 2-D array in a class named Board.

  6. Battleship (Battleship Console Game)

    Battleship. public class Battleship extends java.lang.Object. A console version of the classic Battleship game. The board has 10 rows and 10 columns. The rows are named A-J, the columns are named 1-10. Each position is named by its row and column (e.g., A1 is the upper-left corner of the board).

  7. GitHub

    This repository contains the source code to various problems on Project Stem. Organized by unit, you will find the necessary activity files to be compiled by the Java environment, as well as runner files provided by Project Stem to test execution (when available).

  8. APCSA-ProjectStem/docs/unit8.md at main

    Saved searches Use saved searches to filter your results more quickly

  9. Unit 8: 2D Array

    public class U8_L1_Activity_Two { public static int[][] productTable(int r, int c) { // Initialize Variable int[][] arr = new int[r][c]; // Create Product Table for ...

  10. AP Computer Science A Unit 8 Review

    Topic 8.2 Practice Quiz. Additional Resources. Study Tools. Study Tools. 2024 AP Computer Science A Exam Guide . 6 min read ...

  11. PDF Unit 8: 2D Arrays

    organized in rows and columns like in a spreadsheet, bingo, battleship, theater seats, classroom seats, connect-four game, or a picture. One of our labs, we will implement the Connect Four game. ... you can use assignment statements specifying the row and column of the entry. int[][] matrix = new int[3][4]; //3 rows, 4 columns //all initialized ...

  12. AP CSA Unit 8

    The methods associated with these are the same as regular arrays. The process of traversing a 2D array by accessing all elements in a row before moving on to the next row. The process of traversing a 2D array by accessing all values at the first column in every row, before moving to the next column. Study with Quizlet and memorize flashcards ...

  13. Unit 08

    APCSA. Schedule Frontend API Search AP Standards CTE Standards About. Unit 08 - 2D Array. Student Led Instruction. Dec 6, 2022 • 1 min read Objectives ; Objectives. Make sure lesson has the following... Lesson Purpose and Objectives; Review of Unit Materials and Videos from AP Classroom;

  14. Unit 8 Overview: 2D Array

    Unit Overview Exam Weighting. 7.5-10% of the test. Roughly 3 to 4 multiple-choice questions. Always FRQ #4, which tests your ability to make, traverse, and create algorithms with a 2D array.. Enduring Understanding. In the past two units, you've learned how to store data in an array or an ArrayList.Now it's time to take it to another dimension with 2D arrays.You can either think of them as a ...

  15. Rithika Erumadi

    View Rithika Erumadi - Assignment 8_ Battleship.docx from COMPUTER S EECS224 at University of California, Irvine. Board.java public class Board { private String squares; public Board() { squares =

  16. GitHub

    Contribute to ivan-edu/apcsa-codehs development by creating an account on GitHub. Answers for all units of the APCS CodeHS course. Contribute to ivan-edu/apcsa-codehs development by creating an account on GitHub. ... If an assignment has 2 or more files required, the individual file will be denoted as such: File.name: ----- // Code...

  17. Mr. Carman's Blog

    Here's the plan for this week as we begin Unit 8: 2 D Array: start Unit 8: 2D Array. Unit 8: Lesson 1 - 2-D Array. Unit 8: Lesson 2 - 2-D Array Algorithms. Two-dimensional (2D) arrays can be pretty challenging, so we're going to take this topic slowly and use some graphical organizers to make sure you understand what's going.

  18. Assignment 8: BatttleShip please help if you have answers I ...

    In this assignment, you will create a simple class for playing the game battleship. Battleship is played on a square grid of 10 rows and 10 columns, which you will represent using a 2-D array in a class named Board. A separate class, Battleship, will allow you to try playing your game and see whether the methods work as planned.

  19. APCSA 2020 : r/EdhesiveHelp

    Here is every assignment and coding lesson for APCSA 2020. Hope this helps :) APCSA 2020. Thank you so much! for assignment 6: array statistics, do you have to copy and paste all three parts or just one? If you look on the side of the compiler theirs a 3 tabs with separate parts.

  20. APCSA Unit 8

    In a two-dimensional array represented using an array of arrays (like in Java) this means that the outer array represents the columns and the inner arrays represent the rows. row by row traversal. Use it to print out the 2D array mat by processing one row at a time (row-by-row). Study with Quizlet and memorize flashcards containing terms like ...

  21. APCSA Unit 8

    This code tells java to create an array that can store 2 arrays, each with their own set of 5 indices. array [row] [column] Accesses the element at row row and at column column. Row Major Order. The process of traversing a 2D array by accessing all elements in a row before moving on to the next row. Column Major Order.

  22. PDF AP CSA Pacing Guide

    Week of _____ 25 8 Assignment 8: Battleship Unit 8: Review Unit 8 Exam Lab - Steganography* Week of _____ 26 9 Unit 9: Lesson 1 - Inheritance Unit 9: Lesson 2 - Inheritance Overriding Methods Unit 9 Quiz FRQ - 2D Arrays Week of _____ 27 9 Unit 9: Lesson 3 - Is-a and Has-a Relationships Assignment 9: Ultimate Frisbee

  23. AP Computer Science A Labs

    Create & configure your course assignments. Classroom. Manage & organize your class with customizable settings. Grading. Streamline your grading workflow. Data. ... Exercise 5.1.8 Battleship Extensions. 6. Pokemon Simulation. 6.1 Pokemon Demo. Challenge 6.1.1 The Move Class. Challenge 6.1.2 The Pokemon Class.