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
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