Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please use only JAVA . Thank you. Note: Requirements: Inheritance Correctness an

ID: 3732528 • Letter: P

Question

Please use only JAVA. Thank you.

Note: Requirements:

Inheritance Correctness and Safety

Constructors

Child classes appropriately use parent class constructors to create objects.

@Override tags everywhere they can be

Every time we override a method, we should label it with @Override so that the compiler can ensure we are actually overriding a method as expected. There is an exact list of places this must occur, and it is up to you to discern where.

For @Override tag, it is useful as it enables the compiler to flag errors when a method is meant to override a parent but due to typing errors it is not.

Proper Use of Inheritance for Code Re-Use

Avoid Variable Shadowing

If a parent class already has a field, there is no need for child class to have a similar field. Do not duplicate fields.

Class Documentation

Each class has an initial comment indicating its intended purpose, how it works, and how it relates to or uses other classes in the project.

Field Documentation

Each field of a class is documented to indicate what piece of data is tracked and how it will be used. Fields of all visibilities fields are documented, especially including any you add on your own.

Method documentation

Each method has a short description indicating its intended purpose and how it gets its job done. This especially includes any helper methods you include.

Code Cleanliness

Indent and {bracket} code uniformly throughout the program to improve readability.

Test cases to pass: https://repl.it/@tom_don/WhimsicalPoisedLava

class AlphabetException Class AlphabetException inherits from class RuntimeException. Fields • none. Methods • public AlphabetException(String message). Invokes the parent class's construction, supplying the given message. class Missing CharAlphabetException Class MissingcharAlphabetException extends AlphabetException. Fields • public final char offender • public final Alphabet a Methods • MissingcharAlphabetException (char offender, Alphabet a). Must both store the offender and alphabet a, as well as call the parent constructor with a message of this pattern: "Not in alphabet: 'a' not found in Alphabet (ABC)."

Explanation / Answer

I couldn't find methods in the above question, if you can mention methods in parent class, I can add it to child class via @Override. Also Alphabet class was unclear. What are the fileds that are there in Alphabet class so that I can use the Alphabet variable in the MissingCharAlphabetException constructor to display the variable(ABCDEF) which was passed through constructor of Alphabet(ABCDEF). Please add the corrections if needed, so I can send it again

AlphabetException Class

package com;

// Create a class named AlphabetException which extends RunTimeException

// The motive of this class is to create a Custom Exception by extending Exception class so that

// this class also works as an exception class

public class AlphabetException extends RuntimeException {   

// Constructor with String field

// This Constructor was intended to supply message to its parent class to throw an exception with the message

public AlphabetException(String message) {

super(message); // Calling Parent Constructor with a "message" string

}

MissingCharAlphabetException Class

package com;

// Create a class named MissingCharAlphabetException which extends parent class AlphabetException

// The intention of this class is to call the parent Custom Exception class where we give some

// arguments to the parent constructor to display some message

public class MissingCharAlphabetException extends AlphabetException {

public final char offender; // Created a char field offender used to specify that particular character is not found in Alphabet

public final Alphabet a; // Created a Alphabet field where we use to check offender is present in Alphabet

// Constructor with offender and Alphabet as fields which will pass a string to parent

public MissingCharAlphabetException(char offender, Alphabet a) {

super("Not in Alphabet: '"+offender+"' not found in Alphabet("+")"); // Passing message to the parent constructor saying that offender is not found in the Alphabet

this.offender = offender; // Assigning parameters to the fields of the class

this.a = a; // Assigning parameters to the fields of the class

}

}

Cipher Class

package com;

// This is a abstract class which was intended to encrypt or decrypt messages.

// One can extend this class to provide implementations for encrypt or decrypt messages

public abstract class Cipher {

// This method is a abstract method so it has no body, if you need to implement this method, create a new class

// and extend Cipher class and use @Override to override encrypt method and write your own logic

public abstract String encrypt(String s);

// This method is a abstract method so it has no body, if you need to implement this method, create a new class

// and extend Cipher class and use @Override to override decrypt method and write your own logic

public abstract String decrypt(String s);

}