Question: Java: Please help modify code according to instructions. Thank you. Instructions: Bot Class Subclass of Account class. A class that stores information about an application

Java: Please help modify code according to instructions. Thank you.

Instructions:

  1. Bot Class
    1. Subclass of Account class.
    2. A class that stores information about an application that performs an automated task.
    3. Instance Variables
      1. botFileName String representing the file name of the bot
      2. category String providing the Bot category which will be either IDS, SysAdm, or HelpDesk.
      3. dateUpdated GregorianCalendar object (from the Java API) that shows the date the Bot was last updated.
      4. createdBy String representing the creator name or handle.
    4. Methods
      1. Default constructor sets all instance variables to a default value
        1. Call the super class constructor passing appropriate parameters to it.
        2. Set the rest of the variables
      2. Parameterized Constructor
        1. Takes in all parameters required to set the instance variables.
        2. Call the super class constructor passing appropriate parameters to it
        3. Set the rest of the variables to the remaining parameters
        4. Date is a String in the format mm/dd/yyyy.
        5. Convert the date to a format compatible with creating GregorianCalendar object.
        6. Create the GregorianCalendar object
      3. Accessor and mutator methods for all variables in this class.
      4. toString
        1. Calls super class methods as needed
        2. Returns a nicely formatted String representing the Bot to include Bot file name, purpose, date updated, creator name, accountID number, clearPassword, encryptPassword and key

Code:

import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar;

public class Bot extends Account {

private Calendar dateUpdated = new GregorianCalendar(); private DateFormat dateForm = new SimpleDateFormat("MM/dd/yyyy"); private Date date = new Date(); private String botFileName; private String category; private String createdBy; /** * Constructor to initialize variables. */ public Bot() { super("", ""); setBotFileName(""); setCategory(""); setCreatedBy(""); dateUpdated.setTime(null); }

/** * Constructor to set variables of the Bot Class. */ public Bot(String newBotFileName, String newCategory, String newDate, String newCreatedBy, String newClearPassword, String newKey) { super(newClearPassword, newKey); setBotFileName(newBotFileName); setCategory(newCategory); setCreatedBy(newCreatedBy); setDateUpdated(newDate); }

/** * Method to return the bot's file name */ public String getBotFileName() { return botFileName; }

/** * Method to set the bot file name */ public void setBotFileName(String newBotFileName) { botFileName = newBotFileName; }

/** * Method to return the category of the bot */ public String getCategory() { return category; }

/** * Method to set the bot category * @param newCategory Input category name */ public void setCategory(String newCategory) { category = newCategory; }

/** * Method to return the date the bot file was updated in the Gregorian Calendar format. */ public String getDateUpdated() { return (dateUpdated.get(GregorianCalendar.MONTH) + 1) + "/" + dateUpdated.get(GregorianCalendar.DAY_OF_MONTH) + "/" + dateUpdated.get(GregorianCalendar.YEAR); }

/** * Method to set the date the bot file was updated. * @param newDate Input date of the bot file update */ public void setDateUpdated(String newDate) { try { date = dateForm.parse(newDate); } catch (ParseException e) { e.printStackTrace() ; } dateUpdated.setTime(date); } /** * Method to return the creator of the bot */ public String getCreatedBy() { return createdBy; }

/** * Method to set the name of the person who created the bot * @param newCreatedBy Input name of the person who created the bot */ public void setCreatedBy(String newCreatedBy) { createdBy = newCreatedBy; }

/** * Returns the information for the user. */ public String toString() { String info; info = String.format("%-5s %s %s %s %s ", getBotFileName(), getCategory(), getDateUpdated(), getCategory(), getCreatedBy()); info += super.toString(); return info;

} }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!