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

These are the guidelines: Inheritance - Subclass Course to Section Explanations:

ID: 3714892 • Letter: T

Question

These are the guidelines:

Inheritance - Subclass Course to Section

Explanations: Final Project Video 1

Requirements

Changes to Course:
1. Add default constructor (leave it blank)
2. Add constructor with all attributes
3. You may want to modify the “toString()” once you are finished with the project

Create Section Class: (Inheritance)
1. Extend Course
2. Attributes:
- String id; //e.g. FWT01
- String days; // e.g "WF" for Wednesday Friday or "TTH" for tuesday
- thursday
- String startTime; //e.g. 11AM
- String building; //HL
- String room; //134
3. Add default constructor (leave it blank)
4. Add constructor with all attributes
5. Add all getter and setters
6. Override toString(), be sure to call the super toString()
** for the “days” attribute, there is leeway , you can use a char array or other solution, you can also use a
java.util.date class for the time if you want to

Changes to Student:
1. Change Courses array to Section array
2. Change addCourse() to addSection(), be sure it returns void (we will eventually throw a custom exception)
3. You may want to format the toString(), possibly get rid of the Arrays.toString() or add some line returns

Singleton Design Pattern

Explanations: Final Project Video 2

Create a Singleton DataStore Class
1. Create a DataStore class that implements the Singleton Design Pattern to store data.
2. Read all Section data from a file and store in the singleton class
3. Provide a getSections() method that returns an array of all the sections for the client (in our case the client is
your test class)
4. Instantiate the DataStore from the TestClass and access the data
Additional resources for the singleton design pattern: https://youtu.be/KUTqnWswPV4,
https://youtu.be/SR46F0ryt40

Error handling and Custom Exceptions

Explanations: Final Project Video 3

Create two custom Exceptions
1. Create a DuplicateCourseException
2. Create a MaximumCoursesExceededException
3. Throw appropriate exception in the addSection ( or enroll if that is what you called it) method of the Student
class

Write a Menu Driven program

*for the student to enter information and enroll from the list of available courses
Explanations: Final Project Video 4

1. Ask student for first name, last name, id, address and instantiate a student object.
2. Create a menu from the sections returned from the DataStore class (an array of section objects)
3. Prompt the student to enroll in sections available from the menu
4. Handle the custom exceptions and let the student know if they try to enroll in a duplicate section or if they
have enrolled in too many
5. Provide a "Quit" option in your menu
6. When the user chooses "Quit", automatically print their information and schedule

Thanks for your help!

Explanation / Answer

package org.chegg.meenu;

/**

* Section class

*

* @author Meenu

*

*/

public class Section extends Course{

private String id = "";

private String days = "";

private String startTime ="";

private String building = "";

private String room = "";

Section(){

}

Section(String id,String days,String startTime,String building,String room){

this.id = id;

this.days = days;

this.startTime = startTime;

this.building = building;

this.room = room;

}

public String getId() {

return id;

}

public void setId(String id) {

this.id = id;

}

public String getDays() {

return days;

}

public void setDays(String days) {

this.days = days;

}

public String getStartTime() {

return startTime;

}

public void setStartTime(String startTime) {

this.startTime = startTime;

}

public String getBuilding() {

return building;

}

public void setBuilding(String building) {

this.building = building;

}

public String getRoom() {

return room;

}

public void setRoom(String room) {

this.room = room;

}

public String toString() {

return "Id=" + id + " " + "Days=" + days;

}

}

***************************************************************

package org.chegg.meenu;

/**

* Course class

*

* @author Meenu

*

*/

public class Course{

private String id = "";

private String days = "";

private String startTime ="";

private String building = "";

private String room = "";

Course(){

}

Course(String id,String days,String startTime,String building,String room){

this.id = id;

this.days = days;

this.startTime = startTime;

this.building = building;

this.room = room;

}

public String toString() {

return "Id=" + id + " " + "Days=" + days;

}

public String getId() {

return id;

}

public void setId(String id) {

this.id = id;

}

public String getDays() {

return days;

}

public void setDays(String days) {

this.days = days;

}

public String getStartTime() {

return startTime;

}

public void setStartTime(String startTime) {

this.startTime = startTime;

}

public String getBuilding() {

return building;

}

public void setBuilding(String building) {

this.building = building;

}

public String getRoom() {

return room;

}

public void setRoom(String room) {

this.room = room;

}

}

*******************************************************

package org.chegg.meenu;

/**

* SingletonDesign class

*

* @author Meenu

*

*/

public class SingletonDesign {

private static SingletonDesign instance;

  

private SingletonDesign(){}

  

//static block initialization for exception handling

static{

try{

instance = new SingletonDesign();

}catch(Exception e){

throw new RuntimeException("Exception occured in creating singleton instance");

}

}

  

public static SingletonDesign getInstance(){

return instance;

}

}

*****************************************************

/*
Example of a menu driven program

Create a simple calculator that will add subtract multiply and divide
values entered by the user
*/
import java.util.*; //used to include scanner

public class menuExample
{
public static void main(String args[])
{
//declare a scanner for user Input
Scanner userInput = new Scanner(System.in);
int choice;
int value1, value2
double.number; //hold result of integer value

do
{
//display our menu
System.out.println("*** Calculator v1.0***");
System.out.println("1, Addition");
System.out.println("2, Subtration");
System.out.println("3, Multiplication");
System.out.println("4, Division");
System.out.println("5, Modulos");
System.out.println("6. Exit");
System.out.println("**********************");
System.out.println("Please enter your choice:");

//get user input
choice = userInput.nextInt();

//switch the choice from user
switch(choice)
{
case 1://addition
System.out.println("addition");
System.out.println("Please enter two values to be added");
value1 = userInput.nextInt();
value2 = userInput.nextInt();
System.out.println(value1 + " + " + value2 + " = " + (value1+value2);
break;
case 2://subtraction
System.out.println("subraction");
System.out.println("Please enter two values to be subtrated");
value1 = userInput.nextInt();
value2 = userInput.nextInt();
System.out.println(value1 + " - " + value2 + " = " + (value1-value2);
break;
case 3://multiplication
System.out.println("multiplication");
System.out.println("Please enter two values to be multiplicated");
value1= userInput.nextInt();
value2 = userInput.nextInt();
System.out.println(value1 + " * " + value2 + " = " + (value18value2);
break;
case 4://division
System.out.println("division");
System.out.println("Please enter two values to be divided");
value1= userInput.nextInt();
value2 = userInput.nextInt();
number = (double)value1 / value2; //type cast
System.out.println(value1 + " / " + value2 + " = " + number);
break;
case 5://division
System.out.println("multiplication");
System.out.println("Please enter two values to be divided");
value1= userInput.nextInt();
value2 = userInput.nextInt();
System.out.println(value1 + " % " + value2 + " = " + (value1%value2);
break;
case 6://exit
System.out.println("You have chose exit!");
break;
default://default
System.out.println("You entered an invalid choice");
}
}while(choice != 5);


}//main
}

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