Aim: Write a simple stand-alone Java program from scratch. Simple geometrical reasoning is at the core of Battleships. O
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
Aim: Write a simple stand-alone Java program from scratch. Simple geometrical reasoning is at the core of Battleships. O
GRID FOLLOW ALL THE GUIDELINE AND SHOW THE OUTPUT CODE PLEASE AND
THANK YOU
Aim: Write a simple stand-alone Java program from scratch. Simple geometrical reasoning is at the core of Battleships. One important notion is adjacency, with two sub-types: edge adjacency and corner adjacency. For example, the square (4,3) is edge-adjacent to the square (3,3), it is corner-adjacent to the square (3,2), and it is not adjacent to the square (6,7). Write a program that reads a square from the user, and prints out three lists: 1) a list of all edge-adjacent squares, 2) a list of all corner-adjacent squares, and 3) a list of all squares which are not adjacent at all. Our version of battleships is played on a 7 by 7 board. The lower-left square is (0,0). As noted, the program will read from the console a shot specification. You can decide which formats to handle. They may include, for example, specifications like (5,5) 30 4,1 a7 b 2 An A-level program will handle all the input formats illustrated, output correct answers, be clearly written, and be well designed.
For this assignment. It requires a 7 x 7 board. The following example is a 5 x 5 board It illustrates correspondingly the edge-adjacent, corner-adjacent, and non-adjacent for the point (4,3) // during testing, I may pick any point in the grid To be noticed, (4,1) and (3,1) are just two examples of the non-adjacent. Your program should print all non-adjacent edges. 4 3 2 14,1 14.2 43 4.4 13,1 3,2 3,3 5x5 3.4. For (4.3) | Edge - adjicent (3,2) (4,4) (4.2) A corner-adjient | 1 2 3 4 (312) (3,4) Not-adjcent. ex: (4,1) (3,1)
2. (x,x) | (x,x) | X,X | XX | XX | only these five cases are valid inputs. {0 <= X<7} a. 13 ----- valid b. 1 245 invalid C. ((2'][3)). invalid d. 1 3 ----- invalid e. a1 - invalid 3. For simplicity, any input with alphabets is invalid, such as a1, (a,1), b1, 1a, 2a etc Examples of running a java program in the terminal > javac A1java > java A1.java > Please enter a coordinate: > a3 > invalid input! Please try again: >(4,3) Outputs: Edge-adjacent edges: (3,3) (4,2) (4,4) Coner-adjacent edges: (3,2)(3,4) Non-adjacent edges: (0,0) (0,1) (0,2)......... (3,1) (4,0) (4,1) // you have to print all non-adjacent edges
Edge-adjacent squares Criteria 5 points 2.5 points A list of all correct Some correct edge-adjacent edge-adjacent squares is printed. squares are printed. O points None of the correct edge- adjacent are printed. Corner-adjacent A list of all correct Some correct None of the squares corner-adjacent corner-adjacent correct corner- squares is printed. squares are adjacent squares printed. are printed. Squares which are a list of all correct Some correct not None of the not adjacent at all not adjacent adjacent squares correct not squares is printed. are printed. adjacent squares are printed. Compilation and The program The program is The program has compiles perfectly well written and major compilation and runs as have minor errors. expected. compilation errors. run Total: /20 Bonus: (2 points) (5,5) 30 4,1a7 b 2