src/main/java/seedu/address/MainApp.java
private Model initModelManager(Storage storage, ReadOnlyUserPrefs userPrefs) {
        Optional<ReadOnlyAddressBook> addressBookOptional;
        ReadOnlyAddressBook initialData;
        try {
            addressBookOptional = storage.readAddressBook();
            if (!addressBookOptional.isPresent()) {
                logger.info("Data file not found. Will be starting with a sample AddressBook");
            }

            initialData = addressBookOptional.orElseGet(SampleDataUtil::getSampleAddressBook);
        } catch (DataConversionException e) {
            logger.warning(
                    "Data file not in the correct format. Will be starting with an empty AddressBook");
            initialData = new AddressBook();
        } catch (IOException e) {
            logger.warning(
                    "Problem while reading from the file. Will be starting with an empty AddressBook");
            initialData = new AddressBook();
        }

        Optional<ReadOnlyAddressBookGeneric<Staff>> staffAddressBookOptional;
        ReadOnlyAddressBookGeneric<Staff> staffInitialData;
        try {
            staffAddressBookOptional = storage.readStaffAddressBook();
            if (!staffAddressBookOptional.isPresent()) {
                logger.info("Data file not found. Will be starting with a sample AddressBook");
            }
            staffInitialData = staffAddressBookOptional
                    .orElseGet(SampleDataUtil::getSampleStaffAddressBook);
        } catch (DataConversionException e) {
            logger.warning(
                    "Data file not in the correct format. Will be starting with an empty AddressBook");
            staffInitialData = new StaffAddressBook();
        } catch (IOException e) {
            logger.warning(
                    "Problem while reading from the file. Will be starting with an empty AddressBook");
            staffInitialData = new StaffAddressBook();
        }

        Optional<ReadOnlyAddressBookGeneric<Student>> studentAddressBookOptional;
        ReadOnlyAddressBookGeneric<Student> studentInitialData;
        try {
            studentAddressBookOptional = storage.readStudentAddressBook();
            if (!studentAddressBookOptional.isPresent()) {
                logger.info("Data file not found. Will be starting with a sample AddressBook");
            }
            studentInitialData = studentAddressBookOptional
                    .orElseGet(SampleDataUtil::getSampleStudentAddressBook);
        } catch (DataConversionException e) {
            logger.warning(
                    "Data file not in the correct format. Will be starting with an empty AddressBook");
            studentInitialData = new StudentAddressBook();
        } catch (IOException e) {
            logger.warning(
                    "Problem while reading from the file. Will be starting with an empty AddressBook");
            studentInitialData = new StudentAddressBook();
        }

        Optional<ReadOnlyAddressBookGeneric<Finance>> financeAddressBookOptional;
        ReadOnlyAddressBookGeneric<Finance> financeInitialData;
        try {
            financeAddressBookOptional = storage.readFinanceAddressBook();
            if (!financeAddressBookOptional.isPresent()) {
                logger.info("Data file not found. Will be starting with a sample AddressBook");
            }
            financeInitialData = financeAddressBookOptional.orElseGet(SampleDataUtil::getSampleFinanceAddressBook);
        } catch (DataConversionException e) {
            logger.warning(
                    "Data file not in the correct format. Will be starting with an empty AddressBook");
            financeInitialData = new FinanceAddressBook();
        } catch (IOException e) {
            logger.warning(
                    "Problem while reading from the file. Will be starting with an empty AddressBook");
            financeInitialData = new FinanceAddressBook();
        }

        Optional<ReadOnlyAddressBookGeneric<Course>> courseAddressBookOptional;
        ReadOnlyAddressBookGeneric<Course> courseInitialData;
        try {
            courseAddressBookOptional = storage.readCourseAddressBook();
            if (!courseAddressBookOptional.isPresent()) {
                logger.info("Data file not found. Will be starting with a sample AddressBook");
            }
            courseInitialData = courseAddressBookOptional.orElseGet(SampleDataUtil::getSampleCourseAddressBook);
        } catch (DataConversionException e) {
            logger.warning(
                    "Data file not in the correct format. Will be starting with an empty AddressBook");
            courseInitialData = new CourseAddressBook();
        } catch (IOException e) {
            logger.warning(
                    "Problem while reading from the file. Will be starting with an empty AddressBook");
            courseInitialData = new CourseAddressBook();
        }

        Optional<ReadOnlyAddressBookGeneric<Assignment>> assignmentAddressBookOptional;
        ReadOnlyAddressBookGeneric<Assignment> assignmentInitialData;

        try {
            assignmentAddressBookOptional = storage.readAssignmentAddressBook();

            if (!assignmentAddressBookOptional.isPresent()) {
                logger.info("Data file not found. Will be starting with a sample AssignmentAddressBook");
            }
            assignmentInitialData = assignmentAddressBookOptional
                    .orElseGet(SampleDataUtil::getSampleAssignmentAddressBook);
        } catch (DataConversionException e) {
            logger.warning(
                    "Data file not in the correct format. Will be starting with an empty AssignmentAddressBook");
            assignmentInitialData = new AssignmentAddressBook();
        } catch (IOException e) {
            logger.warning(
                    "Problem while reading from the file. Will be starting with an empty AssignmentAddressBook");
            assignmentInitialData = new AssignmentAddressBook();
        }
        logger.info("Main app check:" + assignmentInitialData.getList().toString());

        Optional<ReadOnlyAddressBookGeneric<Progress>> progressAddressBookOptional;
        ReadOnlyAddressBookGeneric<Progress> progressInitialData;

        try {
            progressAddressBookOptional = storage.readProgressAddressBook();

            if (!progressAddressBookOptional.isPresent()) {
                logger.info("Data file not found. Will be starting with a sample ProgressAddressBook");
            }
            progressInitialData = progressAddressBookOptional
                    .orElseGet(SampleDataUtil::getSampleProgressAddressBook);
        } catch (DataConversionException e) {
            logger.warning(
                    "Data file not in the correct format. Will be starting with an empty ProgressAddressBook");
            progressInitialData = new ProgressAddressBook();
        } catch (IOException e) {
            logger.warning(
                    "Problem while reading from the file. Will be starting with an empty ProgressAddressBook");
            progressInitialData = new ProgressAddressBook();
        }
        logger.info("Main app check:" + progressInitialData.getList().toString());

        return new ModelManager(initialData, staffInitialData, studentInitialData, financeInitialData,
                courseInitialData, assignmentInitialData, progressInitialData, userPrefs);
    }
/**
     * Returns a {@code ModelManager} with the data from {@code storage}'s address book and {@code
     * userPrefs}. <br> The data from the sample address book will be used instead if {@code
     * storage}'s address book is not found, or an empty address book will be used instead if errors
     * occur when reading {@code storage}'s address book.
     */
Returns a  ModelManager with the data from  storage's address book and {@code
userPrefs}.  The data from the sample address book will be used instead if {@code
storage}'s address book is not found, or an empty address book will be used instead if errors
occur when reading  storage's address book.
Returns a ModelManager with the data from storage ' s address book and { @code userPrefs } . The data from the sample address book will be used instead if { @code storage } ' s address book is not found or an empty address book will be used instead if errors occur when reading storage ' s address book .
private Model initModelManager(Storage storage, ReadOnlyUserPrefs userPrefs) {
        Optional<ReadOnlyAddressBook> addressBookOptional;
        ReadOnlyAddressBook initialData;
        try {
            addressBookOptional = storage.readAddressBook();
            if (!addressBookOptional.isPresent()) {
                logger.info("Data file not found. Will be starting with a sample AddressBook");
            }
            initialData = addressBookOptional.orElseGet(SampleDataUtil::getSampleAddressBook);
        } catch (DataConversionException e) {
            logger.warning(
                    "Data file not in the correct format. Will be starting with an empty AddressBook");
            initialData = new AddressBook();
        } catch (IOException e) {
            logger.warning(
                    "Problem while reading from the file. Will be starting with an empty AddressBook");
            initialData = new AddressBook();
        }
        Optional<ReadOnlyAddressBookGeneric<Staff>> staffAddressBookOptional;
        ReadOnlyAddressBookGeneric<Staff> staffInitialData;
        try {
            staffAddressBookOptional = storage.readStaffAddressBook();
            if (!staffAddressBookOptional.isPresent()) {
                logger.info("Data file not found. Will be starting with a sample AddressBook");
            }
            staffInitialData = staffAddressBookOptional
                    .orElseGet(SampleDataUtil::getSampleStaffAddressBook);
        } catch (DataConversionException e) {
            logger.warning(
                    "Data file not in the correct format. Will be starting with an empty AddressBook");
            staffInitialData = new StaffAddressBook();
        } catch (IOException e) {
            logger.warning(
                    "Problem while reading from the file. Will be starting with an empty AddressBook");
            staffInitialData = new StaffAddressBook();
        }
        Optional<ReadOnlyAddressBookGeneric<Student>> studentAddressBookOptional;
        ReadOnlyAddressBookGeneric<Student> studentInitialData;
        try {
            studentAddressBookOptional = storage.readStudentAddressBook();
            if (!studentAddressBookOptional.isPresent()) {
                logger.info("Data file not found. Will be starting with a sample AddressBook");
            }
            studentInitialData = studentAddressBookOptional
                    .orElseGet(SampleDataUtil::getSampleStudentAddressBook);
        } catch (DataConversionException e) {
            logger.warning(
                    "Data file not in the correct format. Will be starting with an empty AddressBook");
            studentInitialData = new StudentAddressBook();
        } catch (IOException e) {
            logger.warning(
                    "Problem while reading from the file. Will be starting with an empty AddressBook");
            studentInitialData = new StudentAddressBook();
        }
        Optional<ReadOnlyAddressBookGeneric<Finance>> financeAddressBookOptional;
        ReadOnlyAddressBookGeneric<Finance> financeInitialData;
        try {
            financeAddressBookOptional = storage.readFinanceAddressBook();
            if (!financeAddressBookOptional.isPresent()) {
                logger.info("Data file not found. Will be starting with a sample AddressBook");
            }
            financeInitialData = financeAddressBookOptional.orElseGet(SampleDataUtil::getSampleFinanceAddressBook);
        } catch (DataConversionException e) {
            logger.warning(
                    "Data file not in the correct format. Will be starting with an empty AddressBook");
            financeInitialData = new FinanceAddressBook();
        } catch (IOException e) {
            logger.warning(
                    "Problem while reading from the file. Will be starting with an empty AddressBook");
            financeInitialData = new FinanceAddressBook();
        }
        Optional<ReadOnlyAddressBookGeneric<Course>> courseAddressBookOptional;
        ReadOnlyAddressBookGeneric<Course> courseInitialData;
        try {
            courseAddressBookOptional = storage.readCourseAddressBook();
            if (!courseAddressBookOptional.isPresent()) {
                logger.info("Data file not found. Will be starting with a sample AddressBook");
            }
            courseInitialData = courseAddressBookOptional.orElseGet(SampleDataUtil::getSampleCourseAddressBook);
        } catch (DataConversionException e) {
            logger.warning(
                    "Data file not in the correct format. Will be starting with an empty AddressBook");
            courseInitialData = new CourseAddressBook();
        } catch (IOException e) {
            logger.warning(
                    "Problem while reading from the file. Will be starting with an empty AddressBook");
            courseInitialData = new CourseAddressBook();
        }
        Optional<ReadOnlyAddressBookGeneric<Assignment>> assignmentAddressBookOptional;
        ReadOnlyAddressBookGeneric<Assignment> assignmentInitialData;
        try {
            assignmentAddressBookOptional = storage.readAssignmentAddressBook();
            if (!assignmentAddressBookOptional.isPresent()) {
                logger.info("Data file not found. Will be starting with a sample AssignmentAddressBook");
            }
            assignmentInitialData = assignmentAddressBookOptional
                    .orElseGet(SampleDataUtil::getSampleAssignmentAddressBook);
        } catch (DataConversionException e) {
            logger.warning(
                    "Data file not in the correct format. Will be starting with an empty AssignmentAddressBook");
            assignmentInitialData = new AssignmentAddressBook();
        } catch (IOException e) {
            logger.warning(
                    "Problem while reading from the file. Will be starting with an empty AssignmentAddressBook");
            assignmentInitialData = new AssignmentAddressBook();
        }
        logger.info("Main app check:" + assignmentInitialData.getList().toString());
        Optional<ReadOnlyAddressBookGeneric<Progress>> progressAddressBookOptional;
        ReadOnlyAddressBookGeneric<Progress> progressInitialData;
        try {
            progressAddressBookOptional = storage.readProgressAddressBook();
            if (!progressAddressBookOptional.isPresent()) {
                logger.info("Data file not found. Will be starting with a sample ProgressAddressBook");
            }
            progressInitialData = progressAddressBookOptional
                    .orElseGet(SampleDataUtil::getSampleProgressAddressBook);
        } catch (DataConversionException e) {
            logger.warning(
                    "Data file not in the correct format. Will be starting with an empty ProgressAddressBook");
            progressInitialData = new ProgressAddressBook();
        } catch (IOException e) {
            logger.warning(
                    "Problem while reading from the file. Will be starting with an empty ProgressAddressBook");
            progressInitialData = new ProgressAddressBook();
        }
        logger.info("Main app check:" + progressInitialData.getList().toString());
        return new ModelManager(initialData, staffInitialData, studentInitialData, financeInitialData,
                courseInitialData, assignmentInitialData, progressInitialData, userPrefs);
    }
private Model initModelManager ( Storage storage , ReadOnlyUserPrefs userPrefs ) { Optional < ReadOnlyAddressBook > addressBookOptional ; ReadOnlyAddressBook initialData ; try { addressBookOptional = storage . readAddressBook ( ) ; if ( ! addressBookOptional . isPresent ( ) ) { logger . info ( "Data file not found. Will be starting with a sample AddressBook" ) ; } initialData = addressBookOptional . orElseGet ( SampleDataUtil :: getSampleAddressBook ) ; } catch ( DataConversionException e ) { logger . warning ( "Data file not in the correct format. Will be starting with an empty AddressBook" ) ; initialData = new AddressBook ( ) ; } catch ( IOException e ) { logger . warning ( "Problem while reading from the file. Will be starting with an empty AddressBook" ) ; initialData = new AddressBook ( ) ; } Optional < ReadOnlyAddressBookGeneric < Staff > > staffAddressBookOptional ; ReadOnlyAddressBookGeneric < Staff > staffInitialData ; try { staffAddressBookOptional = storage . readStaffAddressBook ( ) ; if ( ! staffAddressBookOptional . isPresent ( ) ) { logger . info ( "Data file not found. Will be starting with a sample AddressBook" ) ; } staffInitialData = staffAddressBookOptional . orElseGet ( SampleDataUtil :: getSampleStaffAddressBook ) ; } catch ( DataConversionException e ) { logger . warning ( "Data file not in the correct format. Will be starting with an empty AddressBook" ) ; staffInitialData = new StaffAddressBook ( ) ; } catch ( IOException e ) { logger . warning ( "Problem while reading from the file. Will be starting with an empty AddressBook" ) ; staffInitialData = new StaffAddressBook ( ) ; } Optional < ReadOnlyAddressBookGeneric < Student > > studentAddressBookOptional ; ReadOnlyAddressBookGeneric < Student > studentInitialData ; try { studentAddressBookOptional = storage . readStudentAddressBook ( ) ; if ( ! studentAddressBookOptional . isPresent ( ) ) { logger . info ( "Data file not found. Will be starting with a sample AddressBook" ) ; } studentInitialData = studentAddressBookOptional . orElseGet ( SampleDataUtil :: getSampleStudentAddressBook ) ; } catch ( DataConversionException e ) { logger . warning ( "Data file not in the correct format. Will be starting with an empty AddressBook" ) ; studentInitialData = new StudentAddressBook ( ) ; } catch ( IOException e ) { logger . warning ( "Problem while reading from the file. Will be starting with an empty AddressBook" ) ; studentInitialData = new StudentAddressBook ( ) ; } Optional < ReadOnlyAddressBookGeneric < Finance > > financeAddressBookOptional ; ReadOnlyAddressBookGeneric < Finance > financeInitialData ; try { financeAddressBookOptional = storage . readFinanceAddressBook ( ) ; if ( ! financeAddressBookOptional . isPresent ( ) ) { logger . info ( "Data file not found. Will be starting with a sample AddressBook" ) ; } financeInitialData = financeAddressBookOptional . orElseGet ( SampleDataUtil :: getSampleFinanceAddressBook ) ; } catch ( DataConversionException e ) { logger . warning ( "Data file not in the correct format. Will be starting with an empty AddressBook" ) ; financeInitialData = new FinanceAddressBook ( ) ; } catch ( IOException e ) { logger . warning ( "Problem while reading from the file. Will be starting with an empty AddressBook" ) ; financeInitialData = new FinanceAddressBook ( ) ; } Optional < ReadOnlyAddressBookGeneric < Course > > courseAddressBookOptional ; ReadOnlyAddressBookGeneric < Course > courseInitialData ; try { courseAddressBookOptional = storage . readCourseAddressBook ( ) ; if ( ! courseAddressBookOptional . isPresent ( ) ) { logger . info ( "Data file not found. Will be starting with a sample AddressBook" ) ; } courseInitialData = courseAddressBookOptional . orElseGet ( SampleDataUtil :: getSampleCourseAddressBook ) ; } catch ( DataConversionException e ) { logger . warning ( "Data file not in the correct format. Will be starting with an empty AddressBook" ) ; courseInitialData = new CourseAddressBook ( ) ; } catch ( IOException e ) { logger . warning ( "Problem while reading from the file. Will be starting with an empty AddressBook" ) ; courseInitialData = new CourseAddressBook ( ) ; } Optional < ReadOnlyAddressBookGeneric < Assignment > > assignmentAddressBookOptional ; ReadOnlyAddressBookGeneric < Assignment > assignmentInitialData ; try { assignmentAddressBookOptional = storage . readAssignmentAddressBook ( ) ; if ( ! assignmentAddressBookOptional . isPresent ( ) ) { logger . info ( "Data file not found. Will be starting with a sample AssignmentAddressBook" ) ; } assignmentInitialData = assignmentAddressBookOptional . orElseGet ( SampleDataUtil :: getSampleAssignmentAddressBook ) ; } catch ( DataConversionException e ) { logger . warning ( "Data file not in the correct format. Will be starting with an empty AssignmentAddressBook" ) ; assignmentInitialData = new AssignmentAddressBook ( ) ; } catch ( IOException e ) { logger . warning ( "Problem while reading from the file. Will be starting with an empty AssignmentAddressBook" ) ; assignmentInitialData = new AssignmentAddressBook ( ) ; } logger . info ( "Main app check:" + assignmentInitialData . getList ( ) . toString ( ) ) ; Optional < ReadOnlyAddressBookGeneric < Progress > > progressAddressBookOptional ; ReadOnlyAddressBookGeneric < Progress > progressInitialData ; try { progressAddressBookOptional = storage . readProgressAddressBook ( ) ; if ( ! progressAddressBookOptional . isPresent ( ) ) { logger . info ( "Data file not found. Will be starting with a sample ProgressAddressBook" ) ; } progressInitialData = progressAddressBookOptional . orElseGet ( SampleDataUtil :: getSampleProgressAddressBook ) ; } catch ( DataConversionException e ) { logger . warning ( "Data file not in the correct format. Will be starting with an empty ProgressAddressBook" ) ; progressInitialData = new ProgressAddressBook ( ) ; } catch ( IOException e ) { logger . warning ( "Problem while reading from the file. Will be starting with an empty ProgressAddressBook" ) ; progressInitialData = new ProgressAddressBook ( ) ; } logger . info ( "Main app check:" + progressInitialData . getList ( ) . toString ( ) ) ; return new ModelManager ( initialData , staffInitialData , studentInitialData , financeInitialData , courseInitialData , assignmentInitialData , progressInitialData , userPrefs ) ; }
Returns a {@code ModelManager} with the data from {@code storage}'s address book and {@code
 userPrefs}.
Returns a { @code ModelManager } with the data from { @code storage } ' s address book and { @code userPrefs } .