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

BlueJ Class Edt Tools Options Comile Unde CCoPaste Fnd. lose Source Code publie

ID: 3877227 • Letter: B

Question

BlueJ Class Edt Tools Options Comile Unde CCoPaste Fnd. lose Source Code publie class Applicorion public stotic veid main (String args[1) throws ICExcept ion canner scan nm Scarnar(System.in) String nane String onser Sysean out.prinelnC Hello brother, walcone to your Schadule. " Sysaout.prineln Te Schedule iequire fros you to do sone tasks in raquired tine when you get hoe Sysa, out. prinelCEnter your nasw pleose. noresconl ineC Systan.out.prineLnnanare you golng to cos hore lata? esno orsear scam.Hewlne if Canswer.eaalsC es) nylist.FFroFiC List1.t Systenut.prinelnylist.getListio) eylist-nen ListOfTasks(10); nylist.NodFroeFileC List2. Syste.ot.prineylist gisio) Systen.out.prine rong rut

Explanation / Answer

In the class Task, there exists 4 private members, namely taskName, hour, minute and priority. The default constructor takes 4 values as arguments and stores them in the class members taskName, hour, minute and priority. A toString function is also defined which returns a string value consisting the value of class member. This function is used to print the members of the class.

In the class ListOfTasks, there exists 2 private members; list1 of type Task and sizelist1 of type integer. The default constructor of this class takes an integer sL1 as argument and the variable sizeList1 is initialized with this variable. List1 is then dynamically alocated with sL1 elements of type Task.
In the function readFromfile, myFile opens the file specified by fileName. Then it runs a for loop starting at 0 and terminates at the size of the list. Inside the for loop, p stores the first line, t stores the next line,h stores the line next to t and n stores the 4th line. Now a new task from class Task is initialized as Task1 and takes t,h,m and p as arguments, then the ith position in the list1 is initialized with this task Task1. Finally in the function getList, we first define an empty string called schedule, then we again run a for loop from 0th position to the size of the list as defined in sizeList1. Inside the loop we append the data in List1 to the string schedule after converting the contents to string; finally the string schedule is returned.

Finally in main, the program first prints some relevant information and then takes name and answer as input from the user via the console. If the answer is "yes" then myList is initilized with a size of 5 members of type ListOfTasks; then the list is made to readFromFile 'List1.txt'. This initializes the list with values from 'List1.txt' , and finally the values are printed to the console. If the answer is "no", then myList is initilized with a size of 10 members of type ListOfTasks then it reads data from 'List2.txt' and stores them in the array myList, and finally the list is printed to the console. However if the answer is neither 'yes' or 'no' the program prints 'Wrong Input' to the console and stops execution.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote