Question
In your main/driver class write the following methods: *dayNum which takes in a character and returns the day of week as a number: If the
In your main/driver class write the following methods:
*dayNum which takes in a character and returns the day of week as a number: If the passed in character is M it should return 0. If the char is T it should return 1 If the char is W it should return 2 If the char is R it should return 3 If the char if F it should return 4
*A method assignRoom which takes in an ArrayList of ClassRooms, and a Course that is trying to be scheduled.
This method will attempt to find an open Classroom that can accommodate this Course. First take the days attribute from the Course object you were passed, and break it up into separate characters. For example the days attribute maybe "MWF", in which case you will need to sepeate M, W and F for use below. Hint strings have a method called something like ToCharArray which may help.
*Using a loop you'll go over each ClassRoom in the ArrayList/List you were passed
If the Course fits in the Classroom, keep going. Otherwise, you know you can't put it in this room, so move onto the next room.
You'll next need to see if the ClassRoom is free during the Course time on all days the course is offered. So for example if the course you were pass has days = "MWF", startTime=9 and duration=2, you'll need to see if this Classroom isFree on M at 9 through 10 AND if this Classroom isFree on W at 9-10 and if this Classroom isFree on F at 9-10. Remember you have am method claaed dayNum which converts a day (e.g.M) into a number (e.g.0).
If the classroom is free on all days the course is offered, then you'll schedule it into that room using the schedule method in your Classroom Object. Be sure to schedule it on all days the Course meets. l.e. you'll have to call Schedule multiple times for most courses.
Please answer in Java!!!
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started