🍐 我们总结了加拿大代写中——C++代写的经典案例,如果你有任何CS代写的需要,可以随时联络我们。CoursePear™ From @2009。(SC代写)

PRG255 Term Project

Apartment Door Entry Database Application

Visitors to an appartment can search for the resident by name at the door entry. The door entry will show the apartment number and allow them to select it to ‘buzz’ the resident. The ‘buzz’ is actually a phone call, so the door entry must also have the resident’s phone number. This application is responsible for maintaing the database only. Write a program that creates a file to keep track of residents in an apartment building by name, apartment number, and phone number. The apartment number will be the unique identifier to identify a resident. Each record in the file will be written according to the structure listed below. The program will use the following menu interface:

(C)reate a Resident
(U)pdate a Resident's Information
(D)isplay All Residents
(E)xit

The record structure looks like (note: the size represents the required number of characters without the null character):

Each menu option performs the following actions (note, the program should accept upper or lower case letters for the menu items):

(C)reate a New Resident

This option writes a new record of resident information.
This option must ensure that the apartment number is unique (if the apartment number has already been used, report an error).

(U)pdate a Resident’s Information

This option must prompt the user for which resident’s information they wish to change by asking for the resident’s apartment number. The program must then search for this resident’s apartment number. If the resident cannot be found, an error message should be printed.

Otherwise, the user is then prompted if they want to change the information for each field other than the apartment number and, if so the user is then prompted for the new field information. The new information must replace the old information.

Field Description Type Size

ApartmentNumber int
Name char 45 PhoneNumber char 12

Comments

Resident’s apaartment number
Resident’s name
Resident’s 10-digit phone number including dashes (e.g. 416-555-1212)

(D)isplay All Residents

This option should generate a list of all of the residents. The report should use the following format:

The application is to be developed in three stages as described below. You should complete each stage by its specified due date.

Stage 1

  1. Define a structure to contain the required resident information. Place the structure definition in a file named resident.h. As you continue through this stage and the next two stages of the project, add any declarations you deem appropriate to this header file.
  2. Create the menu part of the program leaving space for the menu actions (create, update, display). For the actions not yet implemented, simply display a message stating “Not Implemented”.
  3. Your main should be in a file called resident.c.
  4. Create an array of structures (make 1000 elements but use a symbolic constant to specify the size) as a local variable in main to contain the resident information. You will also need to keep a local variable with a count of the number of residents in the array (this count should obviously be initialized to 0).
  5. When the user selects (C)reate from the menu, the program should prompt the user for the apartment number. If the apartment number has already been used, the program should display an error and return to the main menu. Otherwise the program should call a function named CreateResident which takes an int parameter for the apartment number. The function should locally create an instance of the resident structure and copy the apartment number into the structure. Then the function should prompt the user for the remaining resident information (name and phone number). Finally the function returns a value of the resident structure type (filled with the resident information entered by the user). Then main should add the new resident to the structure array. Use the LocateResident function to search for a resident with the given apartment number.
  6. When the user selects (D)isplay from the menu, the program will display information for all of the residents in the array. The output should line up into columns as shown above.
  7. The CreateResident function takes an int parameter representing the resident’s apartment number. In the CreateResident function, the user is prompted for all of the resident’s information except the apartment number (Name and Phone Number), and inserts the information into a resident structure. The apartment number is copied into the structure from an int parameter of the function. Once all of the data has been put into the structure, the function then returns it (the return value for the function). The CreateResident function should be in a file named residentutils.c.
  8. The LocateResident function takes 3 parameters: An array of resident structures, the number of residents in the array, and the apartment number of the resident to find. If the resident is found, the function returns the index position in the array where the resident is found. If the resident is not found, the function returns -1. The function uses a linear search to find the resident. The LocateResident function should be in a file named residentutils.c.

Stage 2

  1. When the user selects (U)pdate from the menu, the user is to be prompted for the apartment number of the resident they want to change. The program should then locate the resident (again, use the LocateResident function), and if found, call a function named UpdateResident passing the found resident to the function by address. If the apartment number is not found, a message stating that should appear and the program should return to the main menu.
  2. The UpdateResident function takes a pointer to a resident structure as a parameter and returns nothing (void). The function should prompt the user for the new information for the resident. It should not prompt the user for a new apartment number. For each of the name and phone number, the function should display the current value and ask the user if they would like to change the value. If the user indicates that they would like to change the value, the function will prompt for the new value and update the structure. The UpdateResident function should be in a file named residentutils.c.

Stage 3

  1. When the user selects (E)xit, the program should write the contents of the structure array to a file. The saving should be done from a function named WriteResidents. When the program begins, it should initialize the structure array by reading resident information from a file. The reading should be done from a function named ReadResidents. Don’t forget to also update the resident count variable with the number of residents read from the file.
  2. The WriteResidents function has no return value takes 2 parameters: An array of resident structures and the number of residents in the array. The function opens the file RESIDENT.DAT for writing (output). Use a binary file access. If the file already exists, the file is to be overwritten. The function first writes the number of residents to the file as a binary int value. Then, for whatever the count of the number of residents is, the function writes that number of residents from the resident structure array to the binary file. Do not write the entire array of structures since it is 1000 elements long; only write the number of residents indicated by the count. Note that all of the elements of the structure array that contain resident information can be written to the binary file at one time. The function should be in a file named residentutils.c
  3. The ReadResidents function takes 1 parameter: An array of resident structures. The function returns an int value indicating the number of residents that were read from the file. The function opens the file PATRON.DAT for reading (input). Use a binary file access. If the file does not exist (the first time the program is run, the file PATRON.DAT will not exist), the function simply returns 0

to indicate no residents were read from the file. If the file opens successfully, the function first reads a binary int value representing the number of residents in the file. Then the program reads that number of residents from the file into successive elements of the resident structure array. Note that all of the residents in the file can be read into successive elements of the array at one time. After reading, the function returns the int value representing the number of residents in the file. The function should be in a file named residentutils.c.


CoursePear™是一家服务全球留学生的专业代写
—-我们专注提供高质靠谱的美国、加拿大、英国、澳洲、新西兰代写服务。
—-我们专注提供Essay、统计、金融、CS、经济、数学等覆盖100+专业的作业代写服务。

essay代写

CoursePear™提供各类学术服务,Essay代写Assignment代写Exam / Quiz助攻Dissertation / Thesis代写Problem Set代做等。