Skip to content

Latest commit

 

History

History

CS50 Shirtificate

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

CS50 Shirtificate

This Python program is an implementation to CS50’s Introduction to Programming with Python Week 8 - CS50 Shirtificate Problem Set. The CS50 Shirtificate program, implemented in shirtificate.py, creates a customized PDF certificate with a user's name overlaid on an image of a CS50 "I took CS50" t-shirt.

Program Explanation

The Shirtificate class is a subclass of the FPDF class from the fpdf2 library. It is designed to create a PDF certificate with the following features:

  • The PDF is in portrait orientation.
  • The format of the PDF is A4 (210mm wide by 297mm tall).
  • The top of the PDF says "CS50 Shirtificate" as text, centered horizontally.
  • The shirt's image is centered horizontally.
  • The user's name is on top of the shirt in white text.

How to Use the Program

  1. Open your terminal.

  2. Navigate to the directory where you have saved the shirtificate.py file.

    cd path/to/your/directory
  3. Run the program using the python command:

    python shirtificate.py
  4. The program will interactively prompt you to enter your name.

  5. After entering your name, a file named shirtificate.pdf will be generated in the same directory.

Class Explanation

The Shirtificate class is designed to create a shirtificate with the user's name on it. Here's how it works:

  1. The header method adds the "CS50 Shirtificate" header to the top of the PDF.
  2. The create_shirtificate method adds the shirt's image, the user's name, and other details to the PDF.
  3. The main function collects the user's name, creates an instance of the Shirtificate class, and generates the shirtificate PDF.

How to Test

  1. Open your terminal.

  2. Navigate to the directory where you have saved the shirtificate.py file.

    cd path/to/your/directory
  3. Run the tests using the check50 command:

    check50 cs50/problems/2022/python/shirtificate
  4. The tests will run, and you will see the results indicating whether the program passes each test case.

Submitting Your Work

To submit your work, use the following command in your terminal:

submit50 cs50/problems/2022/python/shirtificate

This will allow CS50 to test your program and provide feedback on its correctness.

Additional Notes

  • The program uses the fpdf2 library to create the PDF certificate.
  • The Shirtificate class extends the functionality of the FPDF class to customize the shirtificate's appearance.
  • The program prompts the user for their name and generates a customized PDF certificate.
  • The generated PDF certificate, shirtificate.pdf, will be created in the same directory as the shirtificate.py file.