![]() ![]() ![]() This a runtime (unchecked) exception that belongs to package java.lang and you that do not have to implement (it already exists). NullPointerException: the argument of a method is null.This a runtime (unchecked) exception that belongs to package java.lang and that you do not have to implement (it already exists). IllegalArgumentException: the argument of a method is no valid.The name and purpose of the exceptions that need to be created for this assignment are: This coordinate will be received by the constructor and stored on an attribute so that getMessage( As all exceptions have to do with coordinates, BattleshipException will have an attribute to store a reference to the coordinate object causing the error situation. The particular text used for the message is up to you: the evaluation tests will not assume any concrete string for it however, it is recommended to include as much information as possible in order to ease the identification of the error. ) which will return a string describing the reason for the exception being thrown.All classes related to exceptions will belong to package model.exceptions.Įvery new exception class will have a method getMessage( We will created an abstract superclass with name BattleshipException from which the rest of exceptions will inherit. In Java, exceptions inherit from the class. If the exception is not handled by any method in the sequence of method invocations, the program is aborted. This method may catch and handle the error situation or abort its execution and return the control to the method that invoked it. When an exception occurs, the normal flow of execution of the program is altered: the method being executed aborts its execution and returns the control to the method that invoked it. Starting with this practical assignment we will handle error situations by means of exceptions. Implement the hierarchy of classes for the boards: classes Board, Board2D and Board3D.Implement the hierarchy of classes for the different types of crafts: classes Craft, Ship, Aircraft and its sub-classes.Implement the hierarchy of classes for the coordinates: classes Coordinate, Coordinate2D, Coordinate3D and CoordinateFactory.Implement the hierarchy of classes for the exceptions: class BattleshipException and its sub-classes.It is strongly recommended that you implement your solution in the very same order followed in this document. model.exceptions for the classes dealing with exception.model.aircraft for the 3D board and aircrafts.The arguments that are references do not need to be checked, unless otherwise stated. When indicated, your code must check that the argument values passed to a method are correct. You will have to decide when to use defensive copy in a setter or getter by looking at the class diagram. Setters or getters which simply return the current value of a property, or set a property to a new value, will not be commented either. ![]() Elements which do not change with regard to the previous assignment will not be explained again. Attributes or relationships will not be covered as they are already shown in the UML diagram. The following sections describe all the methods that you have to modify or implement from scratch for this assignment. These are the UML class diagrams that represent the classes in our model the methods in italics are abstract methods: These classes will use the methods in their sub-classes to implement the logic of the game without having to bother about the type of board (2D or 3D) and type of craft (ship or aircraft) they are working with. Most of the code handling the logic of the game (adding ships or aircrafts, shooting them, etc.) will be in those abstract classes. In order to be able to have 3D and 2D boards, as well as ships and aircrafts with different shapes, and at the same time avoid duplicating our code, we will implement a hierarchy of classes (see the class diagram below), some of which will be abstract. Handling error situations via exceptions.Adding 3D and 2D boards with aircrafts and ships with different shapes to the Battleship game by means of inheritance mechanisms.This assignment will extend the previous one by: We will update it from time to time.īattleship : Aircrafts and 2D/3D boards Introduction If in doubt, first have a look to the ‘Clarifications’ section at the end of this assignment description. Do not submit source code in Latin1 or ISO-8859-1 enconding. IMPORTANT: All your source code must use the UTF-8 character encoding. Third Programming Assignment Deadline: Your assignment must be submitted before Sunday, November 8th, 2020 at 23.59 (Alicante time). Minimal requirements for grading your assignment.Battleship : Aircrafts and 2D/3D boards.PROG3 - Third programming assignment PROG3 - Third programming assignment ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |