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

===== Register.java ==== import java.util.ArrayList; import java.util.HashMap; p

ID: 3809777 • Letter: #

Question

=====Register.java====

import java.util.ArrayList;
import java.util.HashMap;


public class Register {

   public static void main(String[] args) {
       HashMap<Section, ArrayList<String>> roster = new HashMap<>();
       Section s1 = new Section("CSC", 151, 0001, "Bob Charlotte", "Intro to Java");
       Section s2 = new Section("CSC", 151, 0001, "Bob C", "Introduction to Java");
       Section s3 = new Section("CSC", 151, 0001, "B Charlotte", "Java Introduction");
       Section s4 = new Section("CSC", 151, 0002, "Bob C", "Introduction to Java");
       Section s5 = new Section("DBA", 151, 0001, "Bob Charlotte", "SQL 1");
       Section s6 = new Section("CSC", 251, 0001, "Bob Charlotte", "Adv Java");
      
       registerAStudent(roster, s1, "bob");
       registerAStudent(roster, s2, "mike");
       registerAStudent(roster, s3, "peter");
       registerAStudent(roster, s4, "delco");
       registerAStudent(roster, s5, "tobias");
       registerAStudent(roster, s6, "monay");
      
       System.out.println(roster);
   }
  
   public static void registerAStudent(HashMap<Section, ArrayList<String>> roll, Section s, String student) {
       ArrayList<String> victims = roll.get(s);
       if (victims == null) {
           victims = new ArrayList<>();
           victims.add(student);
       }
       else {
           victims.add(student);
       }
       roll.put(s, victims);
   }

}

Create a/chas Section% 5contain Create woks SectionA+containite follmoix4 informatio C4tautSThe r oUMUuul uUformation department (e-4., "CSS" ) courseNumber (e.g., 451 ) e-41 utrsectonNumber (c4.1 1121 ) instructor (eg., "Bob" ) · S4417 title. (ay.,"Teolato'lt-Jan' ) Use Section, objects aite keyr a/ HashMap/uite attached, Register class. Bof, Mike aalPeter shoullMKMP same Register class. Boc, Mike, and Peter should all Ce in same eduster class. ure and leter sito utthe same section. Everyone·k.cue(hint secti 0tla Everyone, eke should be uudt enem secti on s

Explanation / Answer

HI, Please find my implementation of Section Class.

Please let me know in case of any issue.

public class Section {

  

   // instance variables

   private String department;

   private int courseNumber;

   private int sectionNumber;

   private String instructor;

   private String title;

  

   // constructor

   public Section(String department, int courseNumber, int sectionNumber, String instructor, String title) {

       this.department = department;

       this.courseNumber = courseNumber;

       this.sectionNumber = sectionNumber;

       this.instructor = instructor;

       this.title = title;

   }

   public String getDepartment() {

       return department;

   }

   public int getCourseNumber() {

       return courseNumber;

   }

   public int getSectionNumber() {

       return sectionNumber;

   }

   public String getInstructor() {

       return instructor;

   }

   public String getTitle() {

       return title;

   }

   public void setDepartment(String department) {

       this.department = department;

   }

   public void setCourseNumber(int courseNumber) {

       this.courseNumber = courseNumber;

   }

   public void setSectionNumber(int sectionNumber) {

       this.sectionNumber = sectionNumber;

   }

   public void setInstructor(String instructor) {

       this.instructor = instructor;

   }

   public void setTitle(String title) {

       this.title = title;

   }

  

   @Override

   public String toString() {

       return " Department: "+department+" "+

               "Section Number: "+sectionNumber+" "+

               "Course Number: "+courseNumber+" "+

               "Instructor: "+instructor+" "+

               "Title: "+title;

   }

}

import java.util.ArrayList;

import java.util.HashMap;

public class Register {

   public static void main(String[] args) {

       HashMap<Section, ArrayList<String>> roster = new HashMap<>();

       Section s1 = new Section("CSC", 151, 0001, "Bob Charlotte", "Intro to Java");

       Section s2 = new Section("CSC", 151, 0001, "Bob C", "Introduction to Java");

       Section s3 = new Section("CSC", 151, 0001, "B Charlotte", "Java Introduction");

       Section s4 = new Section("CSC", 151, 0002, "Bob C", "Introduction to Java");

       Section s5 = new Section("DBA", 151, 0001, "Bob Charlotte", "SQL 1");

       Section s6 = new Section("CSC", 251, 0001, "Bob Charlotte", "Adv Java");

       registerAStudent(roster, s1, "bob");

       registerAStudent(roster, s2, "mike");

       registerAStudent(roster, s3, "peter");

       registerAStudent(roster, s4, "delco");

       registerAStudent(roster, s5, "tobias");

       registerAStudent(roster, s6, "monay");

       System.out.println(roster);

   }

   public static void registerAStudent(HashMap<Section, ArrayList<String>> roll, Section s, String student) {

       ArrayList<String> victims = roll.get(s);

       if (victims == null) {

           victims = new ArrayList<>();

           victims.add(student);

       }

       else {

           victims.add(student);

       }

       roll.put(s, victims);

   }

}

/*

Sample run:

{

Department: CSC

Section Number: 1

Course Number: 151

Instructor: Bob Charlotte

Title: Intro to Java=[bob],

Department: CSC

Section Number: 2

Course Number: 151

Instructor: Bob C

Title: Introduction to Java=[delco],

Department: DBA

Section Number: 1

Course Number: 151

Instructor: Bob Charlotte

Title: SQL 1=[tobias],

Department: CSC

Section Number: 1

Course Number: 151

Instructor: B Charlotte

Title: Java Introduction=[peter],

Department: CSC

Section Number: 1

Course Number: 151

Instructor: Bob C

Title: Introduction to Java=[mike],

Department: CSC

Section Number: 1

Course Number: 251

Instructor: Bob Charlotte

Title: Adv Java=[monay]}

*/

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