Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write an application in java that models courses, students, and faculty members in a university. General Directions Use proper Java naming conventions. Each class you

Write an application in java that models courses, students, and faculty members in a university. General Directions Use proper Java naming conventions. Each class you create will have private instance variables and any necessary getters and setters, as well as other member variables and methods. Be sure to implement toString() and equals() for each class. Description: Your code should represent the following entities: A student or faculty address consists of a street number, street name, city, state or province, and country. A student of faculty name consists of a first name, last name, and middle initial. A student entity has a name and an address (both represented by an object of class Name and Address,), in addition to a university ID, and a course schedule represented by an ArrayList of Courses (objects of class Course). Your code should provide ways for a specific student to add and drop an existing Course. A faculty has a name and an Address (both represented by an object of class Name and Address,). In addition, a faculty has an employee id number and a teaching schedule, which is an ArrayList of Courses. Provide a way to assign a faculty to teach an existing course and to to find a class in its list and drop it. A course has a course identifier (eg, CS2336) and a number of units (3 credit hours). A university entity maintains lists of students, courses, and faculties. It should be able to list all of them (lists of students, courses, and faculties), to create elements and them to the list. Provide ways to delete students and faculties, for students and faculties to add and delete courses from their course schedules. However, you do not need to provide a way to delete a course from the list of courses. Additional conditions: Your code should be under a package called assignment2.cs2336. Your code should not allow the creation of: o Two students with the same university ID o Two Faculties with the same employee ID o Two classes with the same class identifier Adding the same student more than one to a course should have the same effect as adding it once. Dropping a student not registered in a course from that course will have no effect Two addresses are the same if the whole address is identical. Adding/dropping a student from a course should update the roster of the class. Also, updating the roster of a course will change the affected student course list. Apart from these conditions, you can make any other assumptions, and document them. However, your code should pass all the tests already coded in the driver code attached.

below is drive code

package assignment2.cs2336; public class testUniversityProject { public static void testIdenticalAddresses() { Address address1 = new Address(123, "Spokane Street", "fayettville", "IN", 23458, "USA"); Address address2 = new Address(123, "Spokane Street", "fayettville", "IN", 23458, "USA"); if (address1.equals(address2)) System.out.println("Test testIdenticalAddresses passed."); else System.out.println("Test testIdenticalAddresses failed."); } public static void testDifferentAddresses() { Address address1 = new Address(123, "Spokane Street", "fayettville", "IN", 23458, "USA"); Address address2 = new Address(124, "Spokane Street", "fayettville", "IN", 23458, "USA"); if (address1.equals(address2)) System.out.println("Test testDifferentAddresses failed."); else System.out.println("Test testDifferentAddresses passed."); } public static void testSimpleUniverity() { University mu = new University("Monster University"); try { Student bob_dylan = new Student("Bob","Dylan",'Z',123, "Spokane Street", "fayettville", "IN", 23458, "USA", 123457890); Student rob_frank = new Student("Rob","Frank",'C',425, "Oak Tree Corner", "fayettville", "IN", 23458, "USA", 256111890); Student michelle_alba = new Student("Michelle","Alba",'R',685, "Rio Blvd", "fayettville", "IN", 23458, "USA", 200311820); mu.addStudent(bob_dylan); mu.addStudent(rob_frank); mu.addStudent(michelle_alba); Course cs2336 = new Course("2336", 3); mu.addCourse(cs2336); Faculty amine_belkoura = new Faculty("Mohamed Amine","Belkoura",' ',11025, "Richland Hills Ct", "fayettville", "IN", 23558, "USA", 111223333); mu.addFaculty(amine_belkoura); amine_belkoura.addCourse(cs2336); cs2336.addStudent(bob_dylan); cs2336.addStudent(rob_frank); cs2336.addStudent(michelle_alba); cs2336.dropStudent(michelle_alba); System.out.println("The above string representation of class cs2336 object. " + cs2336.toString()); System.out.println("The above string representation of student Bob Dylan object. " + bob_dylan.toString()); System.out.println("The above string representation of faculty Amine Belkoura object. " + amine_belkoura.toString()); System.out.println("The above string representation of the Monster University object. " + mu.toString()); System.out.println("If the string representation is not of the format CLASS@, then the test testSimpleUniverity passed."); System.out.println("-----------------------------------------------"); } catch (Exception ex) { System.out.println("Cound not create student: " + ex.getMessage()); } } public static void testNotSoSimpleUniverity() { University mu = new University("Monster University"); try { Student bob_dylan = new Student("Bob","Dylan",'Z',123, "Spokane Street", "fayettville", "IN", 23458, "USA", 123457890); Student rob_frank = new Student("Rob","Frank",'C',425, "Oak Tree Corner", "fayettville", "IN", 23458, "USA", 256111890); Student michelle_alba = new Student("Michelle","Alba",'R',685, "Rio Blvd", "fayettville", "IN", 23458, "USA", 200311820); Student mia_white = new Student("Mia","White",'Z',123, "Park Street", "fayettville", "IN", 23458, "USA", 123667890); Student reeba_wyane = new Student("Reeba","Wyane",'C',425, "Coit Avenue", "fayettville", "IN", 23458, "USA", 256011890); Student leo_vespo = new Student("Leo","Vespo",'R',685, "Hilcrest Steet", "fayettville", "IN", 23458, "USA", 200211820); Student sid_farkas = new Student("Sid","Farkas",'Z',123, "Parker Street", "fayettville", "IN", 23458, "USA", 193457890); Student allena_andeeno = new Student("Aleena","Andino",'C',425, "Custer Avenue", "fayettville", "IN", 23458, "USA", 256113890); Student ray_moore = new Student("Ray","Moore",'R',685, "Rio Blvd", "fayettville", "IN", 23458, "USA", 208311820); mu.addStudent(bob_dylan); mu.addStudent(rob_frank); mu.addStudent(michelle_alba); mu.addStudent(mia_white); mu.addStudent(reeba_wyane); mu.addStudent(leo_vespo); mu.addStudent(sid_farkas); mu.addStudent(allena_andeeno); mu.addStudent(ray_moore); Course cs1337 = new Course("1337", 3); Course cs2336 = new Course("2336", 3); mu.addCourse(cs2336); mu.addCourse(cs1337); Faculty amine_belkoura = new Faculty("Mohamed Amine","Belkoura",' ',11025, "Richland Hills Ct", "fayettville", "IN", 23558, "USA", 111223333); Faculty john_lifter = new Faculty("John","Lifter",' ',110, "Drudge Way", "fayettville", "IN", 23559, "USA", 45342); mu.addFaculty(amine_belkoura); mu.addFaculty(john_lifter); amine_belkoura.addCourse(cs2336); john_lifter.addCourse(cs1337); cs2336.addStudent(bob_dylan); cs2336.addStudent(sid_farkas); cs2336.addStudent(michelle_alba); cs2336.dropStudent(michelle_alba); cs2336.addStudent(leo_vespo); cs1337.addStudent(mia_white); cs1337.addStudent(rob_frank); cs1337.addStudent(reeba_wyane); cs1337.addStudent(mia_white); cs1337.addStudent(allena_andeeno); cs1337.addStudent(ray_moore); cs1337.addStudent(leo_vespo); System.out.println("The above string representation of class cs2336 object. " + cs2336.toString()); System.out.println("The above string representation of student Bob Dylan object. " + leo_vespo.toString()); System.out.println("The above string representation of faculty Amine Belkoura object. " + john_lifter.toString()); System.out.println("The above string representation of the Monster University object. " + mu.toString()); System.out.println("If the string representation is not of the format Course@, then the Test testSimpleUniverity passed."); System.out.println("If the string representation is not of the format Course@, then the Test testSimpleUniverity passed."); } catch (Exception ex) { System.out.println("Cound not create student: " + ex.getMessage()); } } public static void testCreateTwoStudentsWithSameID() { University mu = new University("Monster University"); try { Student bob_dylan = new Student("Bob","Dylan",'Z',123, "Spokane Street", "fayettville", "IN", 23458, "USA", 123457890); Student rob_frank = new Student("Rob","Frank",'C',425, "Oak Tree Corner", "fayettville", "IN", 23458, "USA", 123457890); System.out.println("Test testCreateTwoStudentsWithSameID failed."); } catch (Exception ex) { System.out.println("Test testCreateTwoStudentsWithSameID passed."); System.out.println(">>>> Could not create student: " + ex.getMessage()); } } public static void testCreateTwoFacultiesWithSameID() { University mu = new University("Monster University"); try { Faculty bob_dylan = new Faculty("Bob","Dylan",'Z',123, "Spokane Street", "fayettville", "IN", 23458, "USA", 123457890); Faculty rob_frank = new Faculty("Rob","Frank",'C',425, "Oak Tree Corner", "fayettville", "IN", 23458, "USA", 123457890); System.out.println("Test testCreateTwoFacultiesWithSameID failed."); } catch (Exception ex) { System.out.println("Test testCreateTwoFacultiesWithSameID passed."); System.out.println(">>>> Could not create student: " + ex.getMessage()); } } public static void testCreateTwoCoursesWithSameName() { try { Course cs2336_first = new Course("2336", 3); Course cs2336_second = new Course("2336", 3); System.out.println("Test testCreateTwoCoursesWithSameName failed."); } catch (Exception ex) { System.out.println("Test testCreateTwoCoursesWithSameName passed."); System.out.println(">>>> Could not create student: " + ex.getMessage()); } } public static void main(String[] args) { // You can comment one test at a time, and make sure that each one passes. // At the end, you should be able to run all the tests successfully. // testSimpleUniverity(); // testNotSoSimpleUniverity(); // testIdenticalAddresses(); // testDifferentAddresses(); // testCreateTwoStudentsWithSameID(); // testCreateTwoFacultiesWithSameID(); // testCreateTwoCoursesWithSameName(); // Add another test functions to test the following situations // 1- Are two students room mates? // 2- Are two students class mates? } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Microsoft SQL Server 2012 Unleashed

Authors: Ray Rankins, Paul Bertucci

1st Edition

0133408507, 9780133408508

More Books

Students also viewed these Databases questions

Question

=+Describe your point of view.

Answered: 1 week ago