Microsoft Word - PF Assignment 2.docx Programming Fundamentals Assignment XXXXXXXXXXSemester 2 1 ProgrammingFundamentals 2019Semester2 AssignmentChoices We the PF teaching team have allowed for...

i have uploaded the assignment can it be done


Microsoft Word - PF Assignment 2.docx Programming Fundamentals Assignment 2 2019 Semester 2 1 ProgrammingFundamentals2019Semester2 AssignmentChoices We the PF teaching team have allowed for assignment choices considering the diversity of students in PF. Therefore you are required to select either Assignment 2A or Assignment 2B considering your background, skills, aspirations and the type of learner you are (prefer guided/independentlearning).Thetablebelowoutlineaspectsofboth,butyoushoulddoyour ownresearchbeforeselectingone. Assignment2A Assignment2B Assignment2ArequiresadeeperunderstandingofOOconcepts andtheuseofCollectionclasses(ArrayList,HashMap).Some bonusmarksareallocatedtochallengethestudents.Thisproject issuitableifyouareanindependentlearnerandlovechallengesor anadvancedlearner. Assignment2Bguidesyoustepby steptodevelopclasses,subclasses, exceptionsetc.Youneednotmake useofCollectionclasses. Assignment2A:TimetablingandEnrolmentSystem(20marks) 1.Objective The main objective of this assignment is to familiarize you with object oriented design, programming,testingandrefactoring.Thisassignmentisbettersuitedtothosewhohavesome previousprogrammingexperienceandareinterestedintheOOdesignaspects. 2.OverviewandAssumptions TheTimetabling andEnrolment system is a standalone system tobeusednext semester in a newtertiaryinstitution.Atthisstage,theadmin-staff,theonlyuser,willcarryoutalloperations onbehalfofstudentsandstaffs,andyouarerequiredtoconsideronlyone(next)semester.This systemshouldtakeintoaccountcourses,courseofferings,staffs,students,lessons(tutorialsand lectures)andvenues.Theusecasesand theactivitydiagram for thesystemareshown in the appendixIandII. Note,onlysomeof thecourseswillbeofferedeachsemester.Moreover, therecanbeatmost oneoffering for a course ina semester. Students canenrolup to4 coursesandyouneednot consider the course prerequisites. Students however, cannot take two courses where the lectures are overlapping. Moreover a student cannot enrol into a course offering which has alreadyreachedthemaximumnumber. ExistingCourses,StaffsandVenues DetailsofCurrentlyavailablecoursesintheschoolareasfollowsbutnotallthesecourseswill beofferedthissemester.NoteeachcoursecanbeuniquelyidentifiedbasedonCourseID. course1: “P101", "Programming 1", "Teach Basic Programming” course2: “P102", "Programming 2", "Teach Intermediate Programming” course3: “S101", "Software Engineering", "Teach UML and Modelling" course4: “WP1", "Web Programming", "Teach Web Technologies" course5: “UI1", "User Interface", "Teach UI Principles" course6: “Math","Discret Maths","Teach Maths needed for CS" course7: “Net1", "Networking","Teach networking principles" Programming Fundamentals Assignment 2 2019 Semester 2 2 DetailsofCurrentlyavailableVenues in theschoolareas follows.Note thecapacityofvenues varies.Clearlynotwolessonscanbeheldatthesametimeandthesystemshouldcheckforany clashes.Venuecanbeusedfrom8.0to21.00. "12.10.02",100,"Interactive" "12.10.03",200,"Interactive" "10.10.22",36,"Traditional" "10.10.23",36,"Traditional" Currently all tutorials and lectures are takenby the staff from the school.The staff employee number,name,positionandlocationareasfollows: "e44556","Tim O'Connor","Lecturer","14.13.11" "e44321","Richard Cooper","Professor","14.13.12" "e54321","Jane Smith","Lecturer","14.13.13" "e53457", "Isaac Newton", "Associate Professor", "14.13.14" Noteyouarefreetoaddmorecourse,venuesandstaffsfortestingpurpose. 3.Requirements Youarerequiredtowriteamenudrivenprogramthatwillusetheexistingcourses,staffsand venuesdescribedinsectiontwo.Inthefirstphase,themenudrivenprogramcatersmainlyto staffandadminneedsbyallowingcourseofferings,lessons(lecturesortutorials)tobeaddedas wellasassigningaspecificstafftoalesson.Itshouldalsoallowprintingvenue,courseoffering and staff timetables. In the second phase, student specificmenu options should be provided such as enrolling, withdrawing from course offerings and registering, deregistering from tutorialsandprintingstudenttimetables. AddingCourseOffering A course offering must be added before (lessons) lectures or tutorials can be added. When creating a course offering themaximum number of studentsmust be specified. There can at mostbeonecourseofferingforacourse(inagivensemester). AddingLessonsforaCourseOffering Thelessonsintheschoolareeitherlecturesortutorials.Foragivencourseofferingtherecan onlybeonelecturethoughalecturecanlastformanyhours.Foreachlessonthestarttime,the durationandthevenuemustbespecified.Whenaddinglessonsforacourseofferingthesystem should ensure no two lessons for a given course offering can overlap. Moreover the system shouldensurethevenueisnotalreadyusedforotherlessons.Ifalectureisadded,thesystem should ensure the venue capacity for the lecture is adequate for the maximum number of studentsallowedinthecourseoffering. AddingStaff Staffcanbeassignedonlyafterlecturesortutorialsarealreadyadded.Clearlyastaffcannotbe takingtwodifferentlessonsatthesametimeandthesystemshouldcheckforanyclashesand alerttheuserifsuchanattemptismade. Programming Fundamentals Assignment 2 2019 Semester 2 3 StudentRelatedFunctionality EnrollingandWithdrawingStudents Thoughprerequisitesarenotimposedatpresent,nostudentshouldbeallowedtoenrolinmore than4courses.Studentscanhowever,withdrawfromacoursebeforeenrolling inanother. In thecurrentphase,youarenot required toconsider thecensusdate. Students shouldnotbe enrolled into a course offering if it has already reached the maximum capacity. Moreover, students should not be allowed to enrol into two courses where the lecture times are overlapping. RegisteringandDeregisteringintoTutorials Astudentcanregister intoatutorialonly ifalreadyenrolledinthecourseoffering(itbelongs to),themaximumcapacityisnotreachedforthetutorial(36),andtheselectedlessondoesnot clashwithanyoftheothertutorialsforthatstudent.Noteastudentisnotrequiredtoregister intoalecture,asanyenrolledstudentisfreetoattendthelecture.Anyattempttoregisteragain intoatutealreadyregistered,orderegisterfromatutorialwithoutfirstregisteringmustresult inanerrormessagebeingprinted. Sub-MenuOptionsforListingandTimetables ListStudents The system should allow admin to list the students in a course offering or a tutorial using separatemenuoptions. ViewTimetables Thesystemshouldallowtimetablestobeprintedforeachstaff,eachvenue,eachcourseoffering (including all tutorials and lecture) and each student. Note the timetable need not be in a rectangulargridunlessyouareaimingforusabilityandbonusmarks. ProgramSpecificRequirements Inthefirststageyouarenotrequiredtoconsiderthestudents(whichaddstothecomplexity) andyoumayuse the sampledesignsprovided through the classand sequencediagrams.You are however, required to come up with specific test cases (both negative and positive) to demonstrate all requirements are met. You are required to throw and catch the exceptions ClashException, PreExistException and CapacityException. A possible exception class for CapacityExceptionisgivenbelow. public class CapacityException extends Exception { public CapacityException(String cause) { super(cause); } } You may also come up with utility classes with static methods such as Math.max() if such methodspromotereuse. Programming Fundamentals Assignment 2 2019 Semester 2 4 4.Rationale,GuidanceandSuggestions Objectorientedprogramminghelpstosolvecomplexproblemsbycomingupwithanumberof domain classes and associations. However, identifying meaningful classes and interactions requiresa fairamountofdesignexperience. Suchexperiencecannotbegainedbyclassroom- basedteachingalonebutmustbegainedthroughprojectexperience.Wehavestructuredthis assignment(project)intotwophaseswherestudentspecificrequirementscanbedeferreduntil the secondphase.Wehave provided some initialUMLdesign diagrams to foster the habit of designing before commencing on implementation. Marks have been allocated in the final submissionforrefactoringthedesignandcode.Youarealsoencouragedtousecollectionsand exceptions, which simplify the implementation and error propagation. Repetition in this assignment(4timetables)isintendedtomakeyouuseOOtechniquesthatpromotecodereuse (inheritance,polymorphism,utilityclassesandmethods). UseofJavaCollections YouareencouragedtousecollectionssuchasArrayListandHaspMap.ArrayListimplementsan array,whichcangrowindefinitely.HashMapsallowanassociationtobecreatedbetweenkeys and objects. Using such classes also reduce the amount of code required as they provide methodsforretrievingrequiredobjectseasily. ArrayList lessons = new ArrayList(); lessons.add(new Lesson(…………)); Toextractthe4thelement Lesson lesson4 = lessons.get(3); // index starts at 0 YoucanuseHashMapforstoringobjects,whichhaveuniqueprimarykeys.Forexample, HashMap courses = new HashMap(); Toaddacourseweuse: courses.put(new Course("P101", "Programming 1", "Teach Basic Programming")); Toextractthecourseuse: Course course = courses.get("P101"); // returns null if no such course in the map SuggestedDivisionofWork Phase1:Weeks(7–9) Workonindividualclassesandcarryoutsomeunittesting. Phase2:Weeks(10–12) Integrate classes and test the functionalities. In addition, suggested student related functionalitiesbelowshouldbeincorporated FeaturebasedBonusMarks A. Allowallobjectstobestoredinafileandretrieved. B. Printalltimetableinrectangulargridandsavetoafile(sothatitcanbeprinted) Programming Fundamentals Assignment 2 2019 Semester 2 5 AppendixIUseCaseforTimeTablingandStudentEnrolmentSystem Inthecurrentversiononlytheadministratorwillusethesystemtomeetthestaffandstudent needs.Inthesubsequentweb-basedversionbothstaffandstudentswillbeallowedtointeract directly. AddCourse Offering AddLesson AssignStaff EnrolinCourse Offering Withdrawfrom CourseOffering Registerin Tutorial Deregisterfrom Tutorial ListStudents View Timetable ViewStaff Timetable ViewVenue Timetable ViewStudent Timetable ListStudentsin CourseOffering ListStudentsin Tutorial AddLecture AddTutorial ViewCourse Offering Timetable Programming Fundamentals Assignment 2 2019 Semester 2 6 AppendixIIActivity-Diagrams AddCourseOffering AddStaffAddCourse AddVenue AddLecture AddTutorial AssignStafftoLesson EnrolStudentinCourseOffering RegisterStudentinTutorial Programming Fundamentals Assignment 2 2019 Semester 2 7 AppendixIIIPossibleClassDiagram(PhaseI)TimeTabling&StudentEnrolmentSystem Application Courses: HashMap; Venues: HashMap; Staffs: HashMap; createCourseOffering() addLesson(String type) assignStaff() getCourse(cID:String):Course getStaff(sID:String):Staff Course Course(ID:String,name:String, purpose:String) courseId : String name : String objective : String createOffering() getOffering():CourseOffering CourseOffering maxNum : int CourseOffering(maxNum:int,course:Course) addLecture(day:int,start:double,dur:double,ven:Venue) addTutorial(day:int,start:double,dur:double,ven:Venue) getLesson(day:int,start:int,end:int) checkClash(day:int, start) Lesson(abstract) Staff private String eNo; private String name; private String position; private String office; Staff(eNo: String, name: String, position: String, office:String) assign(Lesson lesson) exceptions=ClashException,PreExistException Tutorial Tutorial(day:int,startHr:double,dur:double,venue:Venue, co:CourseOffering) exceptions=ClashException Venue location: String capacity: int purpose: String Venue(location:String, capacity:int, purpose:String) getLessons():ArrayList addLesson(l:Lesson) Lecture Lecture(day:int,startHr:double,dur:double,venue:Venue, co:CourseOffering)exceptions=ClashException,CapacityException * * * * 0. .1 * * startHour: double endHour: double day : int staff: Staff venue Venue co: CourseOffering Lesson(day:int,startHr:double,dur:double,venue:Venue,co:CourseOffering) exceptions=ClashException setStaff(staff:Staff) Programming Fundamentals Assignment 2 2019 Semester 2 8 AppendixIVPossibleSequenceDiagram:AddCourseOffering Application addCourseOffering(ID) course=getCourse(ID) course offering=createOffering() Programming Fundamentals Assignment 2 2019 Semester 2 9 AppendixVPossibleSequenceDiagram:AddTutorial application course=getCourse(ID) course offering=getOffering() offering addTutorial(ID,day,start,dur,venue) addTutorial(day,start,dur,venue) checkClash(day,start,dur)//withotherofferinglessons Tutorial newTutorial(day,start,dur.venue) venue checkClash(day,start,dur) //withothervenuelessons NoteTutorialConstructorwillcallthe superclass(Lesson)constructor Programming Fundamentals Assignment 2 2019 Semester 2 10 AppendixVIPossibleSequenceDiagram:AssignLecturertoLesson(LectureorTutorial) application course=getCourse(ID) course offering=getOffering() offering addTutorial(ID,day,start,dur,venue) lesson=getLesson(day,start) lessonstaff setStaff(staff) staff=getStaff(ID) assignLesson(lesson) checkClash(lesson) add(lesson) Programming Fundamentals Assignment 2 2019 Semester 2 11 Assignment2B:VehicleManagementSystem(20marks) Overview This is a more prescriptive and incremental assignment suitable for those preferring clear guidance (instead of being open ended designs). You are required to complete Part A before proceedingtoPartB,andsimilarlyPartBbeforePartC. PartA:Developa simpleVehicle classwith threestates ‘A’ (available), ‘S’ (servicing)and ’H’ (hired)andmethods.Yourclassmustimplementtherequiredinterfaceandtestitwiththedata provided.InthesecondparttheVehicleclassmustbeusedfordevelopingasimpleapplication. (assignmenttobedemonstratedinweek8toyourlabassistant) PartB: Extend toPremiumVehicle implementing the overriddenmethods (which introduce additional conditions for state transitions). You are also required to develop a menu-driven applicationwherebothVehicleandPremiumVehicleobjectsarestored inacommon array, whichmustbemanipulatedinapolymorphicwaywhenappropriate. service serviceComplete/setodometerreading hire/setHiredDate/TimeandHirer status=‘S’ Hire-complete/set odometerreading&& computecharge status=‘A’ status=‘H’ Vehicleclass service serviceComplete/setodometerreading &&setlast-service hire[carnotdueforservice]/setHiredDate/TimeandHirer status=‘S’ Hire-complete/set odometerreading &&computecharge basedondaysof hireandmileage status=‘A’ status=‘H’ PremiumVehicleclass Programming Fundamentals Assignment 2 2019 Semester 2 12 In part C you are required to extend the menu-driven application developed in section B incorporatingfileandexceptionhandling.Thecustomerdetailsmustalsobeincludedallowing specificdiscounts.AllVehicleandsubclassobjectsmustbewrittentoafilewhenprogramexits and restored back when program commences. The methods should be made to throw appropriateexceptionswhenoperationcannotbeperformed Programming Fundamentals Assignment 2 2019 Semester 2 13 PartAcoversChapters1to6 SectionI WritingaVehicleclass You are required to write a class named Vehicle to manage the hiring of vehicles. The requirementsarespecifiedbelow. InstanceVariables Provideprivate instance variables to store the vehicle-ID, hirer-ID, description, status, daily- rate, odometer-reading and date/time of hire (use the DateTime class provided). Instance variableforstatusofacarmustbesettoeither'A'(available),'H'(hired)or'S'(servicing). Constructor Providea constructor for the class that takesvehicle-ID,description,daily-rateandodometer reading to initialize the corresponding instance variables and to set the instance variable for statusto'A'(availableforhirewhenfirstcreated). publicVehicle(StringvehicleID,Stringdescription,doubledailyRate,intodometer) Methods Providemethodstohireavehicle,completeahire,serviceavehicle,returnavehiclebackfrom service and to print the current state of the vehicle. The hire()must take as argument ID of hirer.Thedate/timeofhireshouldbesettocurrenttimewhichcanbecreatedusingthedefault DateTime constructor (DateTime classdescribed in later section). Thismethod should return false if an attempt ismade to hire a vehiclewhich is currently being serviced (status ‘S’) or alreadyonhire(status‘H’),otherwise(status‘A’)themethodshouldreturntrueaftersettingthe hirerID(totheargumentpassed),thehiredate(tocurrentdate),andstatus(to ‘H’ indicating hired). publicbooleanhire(StringhirerID)//calledwhencarishired Themethodsbelowarerequired forservicingavehicleand forreturningavehicleback from service. These operationsmust return true onlywhen the status of the vehicle are 'A' and 'S' respectively. Note the method serviceComplete(into odo) must set the current odometer reading. publicbooleanservice() //calledwhencarissentforservice publicbooleanserviceComplete(intodo) //calledwhencarisbackfromservice Programming Fundamentals Assignment 2 2019 Semester 2 14 The hireComplete(int odo) must take one argument for odometer reading and return the chargesbasedonthedurationofhireiftheoperationissuccessful,andanegativevalue(-1.0) otherwise. It must succeed only if the status is'H' and the odometer reading is greater than odometerreadingwhencarwashired.Theduration-basedchargecanbecomputedmultiplying daily-rate,bynumberofdays.Assumethatminimumrentaldurationisonedayandthenumber ofdaysiscomputedbasedon24hoursfromthetimeofhire.Forexample,ifJackhiresacarat 9.00amMondaymorningandreturnsitonTuesday10.00am,thehiredurationshouldbesetas twodaysforthepurposeofcomputingthecharges. publicdoublehireComplete(intodo)//calledwhencarhireiscompleted The print() must print the current date and time (using the getCurrentTime() method of DateTimeclass)andthenecessaryvehicledetails(ID,description,daily-rate,status,odometer reading)ofVehicle.Ifthevehicleiscurrentlyonhire,theIDofhireranddate/timeofhiremust alsobeprinted. public void print() OverridethetoStringmethodtoreturntheStringequivalent public Sting toString() This class should also provide accessors for all the instance variables (required for the subclass). Programming Fundamentals Assignment 2 2019 Semester 2 15 DateTimeclassprovided class DateTime { private static long advance; // keeps tracks of any time advance
Oct 03, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here