Assignment 1

Hardware List Maintenance

The goal here is to write some software that would assist a system administrator to maintain a list of IT hardware and owners. The assignment will get progressively more complex as it proceeds – the early stages will be reasonable straight forward and will be sufficient for a passing grade, and the more advanced stages are for those who wish to go further and target a higher overall result.

General Requirements

All assignments should be written in Python 3 and should run in IDLE. They can be written on any type of computer, but they should be able to be executed in the computer pool.

The highest marks will be for working code. However, in cases where there are problems, you will be assigned marks for how you approached the task. It is also expected that you will provide comments in the programs to explain how it works, and these comments will account for up to 10% of the overall grade.

Stage 1: Data Entry

Write a program which requests that the user enters a computer model, year purchased, blue plate number (a unique ID that will be used to identify the computer) and owner. Store that data in a List. After the user has entered data, request that the user enters Y or N to continue. If they enter N, print the list of models, years, owners and blue plate numbers to the screen. If they enter Y, repeat the first step.

Your program should produce the following result:

Hardware Manager
Computer Model: Acer Aspire 5
Purchase Year: 2018
Blue Plate: A87634
Owner: Gaye Deegan
Acer Aspire 5 (2018) A87634 has been recorded.
Do you wish to enter another record? (Y/N) Y
Computer Model: Lenovo Yoga 520
Purchase Year: 2017
Blue Plate: G65438
Owner: Ben Martini
Lenovo Yoga 520 (2017) G65438 has been recorded.
Do you wish to enter another record? (Y/N) N
1. Acer Aspire 5 (2018) A87634: Gaye Deegan
2. Lenovo Yoga 520 (2017) G65438: Ben Martini
Thankyou.

Stage 2: Validation

Building on stage 1, you now need to ensure that the program checks for valid entries in each case, and converts the text to the appropriate format.

You need to:

  • Ensure that a model, year, blue plate number and owner were entered, If any of these were not entered, do not record that item and go straight to asking if they wish to continue.
  • Ensure that the user enters either “Y”, “y”, “N” or “n” when asked if they wish to continue. Continue to ask until they enter a valid result.
  • For extra marks, (and this is challenging), ensure that the blue plate number consists of a letter followed by five numerals.

Sample output:

Hardware Manager
Computer Model: Acer Aspire 5
Purchase Year: 2018
Blue Plate: A87634
Owner: Gaye Deegan
Acer Aspire 5 (2018) A87634 has been recorded.
Do you wish to enter another record? (Y/N) yes
Do you wish to enter another record? (Y/N) y
Computer Model:
No record has been recorded.
Do you wish to enter another record? (Y/N) Y
Computer Model: Lenovo Yoga 520
Purchase Year: 2017
Blue Plate: G65438
Owner: Ben Martini
Lenovo Yoga 520 (2017) G65438 has been recorded.
Do you wish to enter another record? (Y/N) N
1. Acer Aspire 5 (2018) A87634: Gaye Deegan
2. Lenovo Yoga 520 (2017) G65438: Ben Martini
Thankyou.

Stage 3: Objects and Persistance

This involves two separate jobs:

  • Create a class to store the details of the record rather than using a List on its own. Employ the Class in your code.
  • Store the record details in a text file, and load then when next the program is launched.

Sample Output

Hardware Manager
Computer Model: Acer Aspire 5
Purchase Year: 2018
Blue Plate: A87634
Owner: Gaye Deegan
Acer Aspire 5 (2018) A87634 has been recorded.
Do you wish to enter another record? (Y/N) N
1. Acer Aspire 5 (2018) A87634: Gaye Deegan
Thankyou.

Hardware Manager
Computer Model: Lenovo Yoga 520
Purchase Year: 2017
Blue Plate: G65438
Owner: Ben Martini
Lenovo Yoga 520 (2017) G65438 has been recorded.
Do you wish to enter another record? (Y/N) N
1. Acer Aspire 5 (2018) A87634: Gaye Deegan
2. Lenovo Yoga 520 (2017) G65438: Ben Martini
Thankyou.

Stage 4: Options and CSV

In this stage we need to add an optional “Export to CSV” option, along with the ability to choose to list existing entries and/or add a new one. The program should now ask the user to choose between 4 options: Add a new account, List existing accounts, Export to CSV, or Quit. If they do not choose one of those four options, they need to be asked again. If they choose Export, we need to output the data to accounts.csv. Otherwise we need to add, list or quite as required.

Now that things are getting more complex, you are expected to use functions to manage these tasks in your program.

Sample output:

Hardware Manager

    (A)dd a new record

    (L)ist existing records

    (E)xport to CSV

    (Q)uit

Your choice: A

Computer Model: Acer Aspire 5

Purchase Year: 2018

Blue Plate: A87634

Owner: Gaye Deegan

Acer Aspire 5 (2018) A87634 has been recorded.

    (A)dd a new record

    (L)ist existing records

    (E)xport to CSV

    (Q)uit

                                                                                             callnow Button

Your choice: L

  1. Acer Aspire 5 (2018) A87634: Gaye Deegan

    (A)dd a new record

    (L)ist existing records

    (E)xport to CSV

    (Q)uit

Your choice: a

Computer Model: Lenovo Yoga 520

Purchase Year: 2017

Blue Plate: G65438

Owner: Ben Martini

Lenovo Yoga 520 (2017) G65438 has been recorded.

    (A)dd a new record

    (L)ist existing records

    (E)xport to CSV

    (Q)uit

Your choice: e

Records saved as hardware.csv.

    (A)dd a new record

    (L)ist existing records

    (E)xport to CSV

    (Q)uit

Your choice: Q

Thankyou.

Stage 5: Deleting and Updating

For the last stage we need to make this a bit more general purpose by introducing methods to delete and update records. As we’re doing this, we will also need to record when events happen. Accordingly, you will need to add:

  • A date/time created property in the record.
  • A date/time updated property in the record.
  • An ability to delete a record, where the user enters the ID (number) of the record and it is removed after confirming the record with the user. You will need to learn how to delete an item from a List and to update the save file.
  • The ability to edit a record by changing the owner’s name. As with delete, the user will need to specify the ID of the record to be edited. If no ID is specified, or if the ID is incorrect, it will not continue.

Sample output:

Hardware Manager

    (A)dd a new record

    (L)ist existing records

    (C)hange owner

    (D)elete a record

    (E)xport to CSV

    (Q)uit

Your choice: A

Computer Model: Acer Aspire 5

Purchase Year: 2018

Blue Plate: A87634

Owner: Gaye Deegan

Acer Aspire 5 (2018) A87634 has been recorded.

    (A)dd a new record

    (L)ist existing records

    (C)hange owner

    (D)elete a record

    (E)xport to CSV

    (Q)uit

Your choice: l

  1. Acer Aspire 5 (2018) A87634: Gaye Deegan

    Created: Tuesday, 05. March 2018 07:25AM

    Updated: Tuesday, 05. March 2018 07:25AM

    (A)dd a new record

    (L)ist existing records

    (C)hange owner

    (D)elete a record

    (E)xport to CSV

    (Q)uit

Your choice: d

Enter record ID: 1

You are about to delete Acer Aspire 5 (2018) A87634

Do you wish to delete this record (Y/N): N

    (A)dd a new record

    (L)ist existing records

    (C)hange owner

    (D)elete a record

    (E)xport to CSV

    (Q)uit

Your choice: d

Enter record ID: 1

You are about to delete Acer Aspire 5 (2018) A87634

Do you wish to delete this record (Y/N): Y

Record deleted.

    (A)dd a new record

    (L)ist existing records

    (C)hange owner

    (D)elete a record

    (E)xport to CSV

    (Q)uit

Your choice: l

No records to display

    (A)dd a new record

    (L)ist existing records

    (C)hange owner

    (D)elete a record

    (E)xport to CSV

    (Q)uit

Your choice: a

Computer Model: Lenovo Yoga 520

Purchase Year: 2017

Blue Plate: G65438

Owner: Ben Martini

Lenovo Yoga 520 (2017) G65438 has been recorded.

    (A)dd a new record

    (L)ist existing records

    (C)hange owner

    (D)elete a record

    (E)xport to CSV

    (Q)uit

Your choice: l

  1. Lenovo Yoga 520 (2017) G65438: Ben Martini

    Created: Tuesday, 05. March 2018 07:30AM

    Updated: Tuesday, 05. March 2018 07:30AM

    (A)dd a new record

    (L)ist existing records

    (C)hange owner

    (D)elete a record

    (E)xport to CSV

    (Q)uit

Your choice: C

Enter record ID: 2

There are no records with the ID “2”.

    (A)dd a new record

    (L)ist existing records

    (C)hange owner

    (D)elete a record

    (E)xport to CSV

    (Q)uit

Your choice: C

Enter record ID: 1

Enter a new owner: Gaye Deegan

Lenovo Yoga 520 (2017) G65438 has been updated.

    (A)dd a new record

    (L)ist existing records

    (C)hange owner

    (D)elete a record

    (E)xport to CSV

    (Q)uit

Your choice: l

  1. Lenovo Yoga 520 (2017) G65438: Gaye Deegan

    Created: Tuesday, 05. March 2018 07:30AM

    Updated: Tuesday, 05. March 2018 07:32AM

—–

    (A)dd a new record

    (L)ist existing records

    (C)hange owner

    (D)elete a record

    (E)xport to CSV

    (Q)uit

Your choice: Q

Thankyou.

 

Leave a Reply