CPS511 Assignment 1: Galaga Simple CPS209 Assignment 2: Extended Student Registry Simulator Due Date: Wed April 6 11:59pm You are to extend the Student Registry Simulator program from assignment 1....

hi, i am a university student and have a Java assignment completed which is worth 10 percent of my grade. The assignment builds on a previously constructed assignment which is in the compressed file labeled CPS209-A1-ExampleSolutions and requires the student to read text files into the java program and handle exceptions accordingly. My dead line is a week away. How much would this cost? The assignment needs to completely work according to the description provided in the files below.


CPS511 Assignment 1: Galaga Simple CPS209 Assignment 2: Extended Student Registry Simulator Due Date: Wed April 6 11:59pm You are to extend the Student Registry Simulator program from assignment 1. This programming assignment will increase your knowledge of Java Collections, file IO and exceptions, objects and classes, inheritance, and interfaces. You must do this assignment alone – no groups. Do not attempt to find source code on the web for this assignment. It will not help you and you risk extremely serious consequences. Your program will be checked for plagiarism. Begin designing and programming early! This assignment is worth 10 percent of your mark. If there is some part of the assignment you do not understand, please email me as soon as possible and I will clarify the issue. NOTE: some parts of the assignment are using java concepts (specifically Maps) for which I have not yet posted the lecture presentation with audio. I will be posting it later this week. Program Functionality Requirements: Please look at the video included with this assignment. Below is a description of the new class for your assignment and some new methods and other modifications. NOTE: I would like you to extend your assignment 1 (A1) and keep the classes essentially as they were except for changes and additions specified below. I strongly suggest you build your program in pieces. Get one piece compiled and working before working on the next piece. Read the marking scheme below and use it as a guide. You are permitted to add other instance variables and other methods if you think they are necessary. NOTE WELL!!: if you want to extend my solution to assignment 1, then I will post it by early next week, once everyone has handed in their assignment 1. 1. ActiveCourse: Add new instance variables int lectureStart, int lectureDuration, String lectureDay. You can use different names if you prefer. These variables will be set/used by the new Scheduler class. 2. Registry: There are several changes and additions to the Registry class: a. Change the constructor method so that the student names and ids are read from a file called students.txt. I suggest you create a helper method that reads this file one line at a time. Each line should contain the student name and id. You will have to handle IOExceptions. Catch Exceptions in the main method by surrounding the lines Registry registry = new Registry(); by a try{..} catch{..} block. Once you have read a student name and id from the file, proceed as usual – create a Student object and add it to the TreeMap (or ArrayList if you are not able to convert to a TreeMap). b. Change both array lists students and courses to TreeMap rather than ArrayList. Use the student id as the key for the students TreeMap and use the course code as the key for the courses TreeMap. You will then have to modify the code in several of the methods of class Registry to use a Map rather than an ArrayList. Study the Collections lecture slides for Maps and Sets. I will be posting a lecture presentation with audio sometime this week which will help you. 3. Add a new class Scheduler. This class is responsible for scheduling active courses. There will be 3 new commands added to the StudentRegistrySimulator that use the Scheduler. These 3 new commands will be explained in point 4. below. A minimal amount of skeleton code has been provided for you for Scheduler. Here are some suggested public methods for this class (note – add any other helper methods or variables you think you need): a. public Scheduler(TreeMap courses). A constructor method that takes a reference to a TreeMap of active courses. In the main method of class StudentRegistrySimulator, after you have created a Registry object, you should create a Scheduler object and pass in the courses (formerly an ArrayList of ActiveCourse) treemap from the registry. Initialize the schedule instance variable. See the skeleton code. This constructor method has been written for you. b. public void setDayAndTime(String courseCode, String day, int startTime, int duration). Given a courseCode and other parameters, this method will set the variables lectureDay, lectureStart, lectureDuration of the corresponding active course object. However, this method does extensive error checking first before setting these variables. If there is an error in one of the parameters, then this method should throw an appropriate exception. These exceptions should be caught in the main method of class StudentRegistrySimulator. I suggest you create your own custom exceptions by extending RuntimeException (see the example in the lecture slides). Here is the error checking this method should support · UnknownCourse exception: the given courseCode cannot not be found · InvalidDay exception: the string parameter day should be one of “Mon”, “Tue”, “Wed”, “Thur”, “Fri”. · InvalidTime exception: the startTime parameter should not be less than 0800 (8 am) and the end time of the lecture (based on the duration parameter) should not be greater than 1700 (5pm). Use a 24 hour clock. · InvalidDuration parameter: the lecture duration should be 1, 2 or 3 hours. · LectureTimeCollision exception : the day, startTime, and duration should be such that it does not create any overlap with another scheduled course. c. public void clearSchedule(String courseCode). Given the course code, reset the lectureDay to “”, lectureStart to 0 and lectureDuration to 0 of the ActiveCourse object. If no such active course exists, do nothing. d. public void printSchedule(). See the video. Prints the timetable in a nice format. Feel free to make your formatting nicer than mine but it must be “2D” with hours along the left side and days across the top. e. NOTE: only allow a course to be scheduled for a single block of time during the week. If it is already scheduled, then just over write the current schedule. See the bonus below 4. Modify class StudentRegistrySimulator. Add three new commands: a. “SCH courseCode day start duration”. See the video. For example: sch cps209 Mon 900 3. Schedules a course for a certain day, start time and duration. Don’t forget to catch any exceptions thrown. Print an appropriate message to the user if an exception is thrown. b. “CSCH courseCode”. Clears the schedule of the given course c. “PSCH” Prints the entire schedule. 5. BONUS: a. Extend the scheduler to handle multiple blocks of time for a course during the week. For example, cps209 could have a 2 hour lecture on Fridays from 0800-1000 and a 1 hour lecture from 0900-1000 on Wednesdays. b. For ambitious students, make the scheduler more automatic. Given a course code and a lecture duration, the scheduler automatically finds a block of time during the week. If it cannot, it throws an exception. If it succeeds, when you print the schedule, you should see the course has been scheduled. Grading (Out of 10 marks) Highest Grade Possible: 12 File I/O and exception handling for reading the students.txt file and populating the registry with students 3 marks Changing the array lists students and courses in Registry to TreeMaps and altering the methods appropriately in class Registry 2 marks Scheduler implementation and 3 new commands 5 marks Bonus a 1 mark Bonus b 1 mark Penalty for insufficient comments or bad program structure or bad use of exceptions, maps etc Up to -1 marks Submitting Your Assignment: READ CAREFULLY!! · Use D2L to submit your assignment. · Inside each of your “.java” files have your name and student id as comments at the top of the file. Make sure your files can be compiled as is without any further modification!! · Include a README.txt file that describes what aspects of your program works and what doesn't work (or partially works). If your program does not compile, state this!! You will still get part marks. The TA will use this file as a guide and make fewer marking mistakes. · Place all your “.java” file(s) and README.txt file into an archive (zip or rar archiving format only). · Open your archive and make sure your all your files are there. · Do not include ".class" files!!!! · Do not use any Package keyword in your java files!!! · Once everything is ready, submit it. import java.util.ArrayList; import java.util.Set; import java.util.TreeMap; public class Scheduler { // In main() after you create a Registry object, create a Scheduler object and pass in the students ArrayList/TreeMap // If you do not want to try using a Map then uncomment // the line below and comment out the TreeMap line //ArrayList students; TreeMap schedule; public Scheduler(TreeMap courses) { schedule = courses; } public void setDayAndTime(String courseCode, String day, int startTime, int duration) { // see assignment doc } public void clearSchedule(String courseCode) { // see Assignment doc } public void printSchedule() { // see assignment doc } } Lavf55.33.100 Lavf55.33.100
Mar 30, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here