Initial transfer of larger repo from git. IF full history and branches are needed must go to github at https://github.com/DulcisL/CCUCoding.git
This commit is contained in:
commit
c09ce40be0
4048 files changed
+603256
No files matched your search
@@ -0,0 +1,40 @@
|
||||
#modules
|
||||
#https://docs.python.org/3/py-modindex.html
|
||||
#python Docs
|
||||
#https://docs.python.org/3
|
||||
import calendar as cs
|
||||
import libraryFile
|
||||
import onlineLibFile
|
||||
#use the library imported by typing library
|
||||
#use the dot to call the Library class to create an instance
|
||||
print(cs.TextCalendar)
|
||||
#lib is the instance variable
|
||||
#library is the module
|
||||
#Library is the class
|
||||
lib = libraryFile.Library('module Lib', 100, 'The Mod worker name')
|
||||
print(lib)
|
||||
subLib = onlineLibFile.OnlineLib('mobLib.com', 'online', 2000, 'you', True)
|
||||
print(subLib)
|
||||
#create a module for the library class
|
||||
|
||||
#test the module for checking is a password is valid
|
||||
#import module to use the passwordChecker
|
||||
import checkPassword
|
||||
password = input('Enter a paSsword \n (must have 1 capital letter, 1 number and 8 characters): ')
|
||||
if checkPassword.checkPassword(password):
|
||||
print(f'password {password} is accepted')
|
||||
else:
|
||||
print('password not accepted')
|
||||
|
||||
#classes and methods in separate files
|
||||
#Multiple inheritances
|
||||
#private Methods
|
||||
# Polymorphism
|
||||
# Polymorphism in python defines methods in the child class that have the same name as the
|
||||
# methods in the parent class. In inheritance, the child class inherits the methods from the
|
||||
# parent class. Also, it is possible to modify a method in a child class that it has inherited
|
||||
# from the parent class.
|
||||
# duck typing
|
||||
# Duck typing is a concept related to dynamic typing, where the type or the class of an
|
||||
# object is less important than the methods it defines. When you use duck typing, you do not
|
||||
# check types at all. Instead, you check for the presence of a given method or attribute
|
||||
@@ -0,0 +1,35 @@
|
||||
#program header
|
||||
''' Name:
|
||||
Date: 09/28/2022
|
||||
Assignment: Password Check Module
|
||||
Pseudocode:(when needed)
|
||||
Module to check if a password contains at least 1 capital letter,1 number, and 8 characters
|
||||
'''
|
||||
|
||||
def checkPassword(password: str):
|
||||
#8 characters
|
||||
#pass in the user password as an attribute(variable) to the method
|
||||
#count each character of the string -> len() is the method to count a string
|
||||
# check if the count is at least 8
|
||||
if len(password) >= 8:
|
||||
# 1 capital letter
|
||||
#check each character of the string and deterine if one is capital
|
||||
counter = 0
|
||||
while counter < len(password):
|
||||
#this will be a charcater in the password string
|
||||
charcterToCheck = password[counter]
|
||||
if charcterToCheck.isupper():
|
||||
break
|
||||
counter += 1
|
||||
# 1 number
|
||||
numberCounter = 0
|
||||
while numberCounter < len(password):
|
||||
#this will be a charcater in the password string
|
||||
charcterToCheck = password[numberCounter]
|
||||
if charcterToCheck.isalnum():
|
||||
return True
|
||||
numberCounter += 1
|
||||
return False
|
||||
else:
|
||||
return False
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
#Class Library
|
||||
class Library ():
|
||||
# has a name, numberOfBooks, librarian and optional open.
|
||||
_name = str #defines a string
|
||||
_numberOfBooks = int #defined as an integer
|
||||
_librarian = str
|
||||
_open = bool # defines a boolean
|
||||
_booksCheckedOut = list #defines an empty list
|
||||
|
||||
#Supply an appropriate constructor
|
||||
#attributes with data types name: str
|
||||
#The open is optional
|
||||
#If the value is not set when the constructor initializes, the value to true
|
||||
def __init__(self, name: str, numberOfBooks: int, librarian: str, open = True):
|
||||
#initialize instance variables
|
||||
self._name = name
|
||||
self._numberOfBooks = numberOfBooks
|
||||
self._librarian = librarian
|
||||
self._booksCheckedOut = []
|
||||
self._open = open
|
||||
|
||||
#getters
|
||||
def getName(self):
|
||||
return self._name
|
||||
def getNumberOfBooks(self):
|
||||
return self._numberOfBooks
|
||||
def getLibrarian(self):
|
||||
return self._librarian
|
||||
def getOpen(self):
|
||||
return self._open
|
||||
#setters
|
||||
def setName(self,name):
|
||||
self._name = name
|
||||
def setNumberOfBooks(self, numberOfBooks):
|
||||
self._numberOfBooks = numberOfBooks
|
||||
def setNLibrarian(self, librarian):
|
||||
self._librarian = librarian
|
||||
def setOpen(self, open):
|
||||
self._open = open
|
||||
|
||||
#actions, methods, behaviors
|
||||
#checkOutBook(str bookName)
|
||||
#assumption any book is avaliable that is not currently checked out
|
||||
|
||||
def checkOutBook(self, bookName: str):
|
||||
'''Description: This method is designed to add a book to the library house object list
|
||||
Parameters:
|
||||
bookName (str): contains the name of the book to checkout
|
||||
Return:
|
||||
(str) - To give the status of adding the book
|
||||
'''
|
||||
#check if book is already checked in
|
||||
if bookName in self._booksCheckedOut:
|
||||
return 'Sorry that book is checked out, try another.'
|
||||
else:
|
||||
self._booksCheckedOut.append(bookName)
|
||||
return f'{bookName} is checked out.'
|
||||
|
||||
#printBooksCheckedOut()
|
||||
# Book 1: name
|
||||
# Book 2: name
|
||||
# Book 3: name
|
||||
# .....
|
||||
def printBooksCheckedOut(self):
|
||||
'''Description: The method is desgined to print the books checked out
|
||||
Parameters:
|
||||
none
|
||||
Return:
|
||||
nothing
|
||||
'''
|
||||
bookCount = 1
|
||||
for book in self._booksCheckedOut:
|
||||
print(f'Book {bookCount} {book}')
|
||||
bookCount += 1
|
||||
#to string (print method)
|
||||
# a print method that prints the following
|
||||
#------- Library name entered ----------
|
||||
# Number of books:
|
||||
# The Librarian is:
|
||||
#
|
||||
def __str__(self):
|
||||
return f'Library Name: {self._name} -> Number of Books: {self._numberOfBooks} -> Open: {self._open}'
|
||||
|
||||
|
||||
#take all data from the user
|
||||
#create an inherited instance of class (object)
|
||||
#make a list of objects and print a list
|
||||
@@ -0,0 +1,43 @@
|
||||
#Import the main class for inheritance
|
||||
from libraryFile import *
|
||||
#create an inherited class
|
||||
# (Library) is the class inherited
|
||||
class OnlineLib (Library):
|
||||
#Attributes
|
||||
|
||||
_url = str
|
||||
_searchItem = str
|
||||
|
||||
#Constructor
|
||||
def __init__ (self, url: str, name: str, numberOfBooks: int, librarian: str, open: bool = True):
|
||||
# Initializes the attributes of the parent class Library
|
||||
super().__init__(name, numberOfBooks, librarian, open)
|
||||
self._url = url
|
||||
self._searchItem = ''
|
||||
|
||||
#Getters / setters
|
||||
def setUrl (self, url: str):
|
||||
self._url = url
|
||||
def setSearchItem (self, searchItem: str):
|
||||
self._searchItem = searchItem
|
||||
def getUrl (self):
|
||||
return self._url
|
||||
def getSearchItem (self):
|
||||
return self._searchItem
|
||||
#Actions
|
||||
|
||||
#Chatbot
|
||||
def chatBot (self):
|
||||
print('Start Chatbot')
|
||||
#search
|
||||
def searchLib (self):
|
||||
print(f'Searching {self._searchItem}')
|
||||
|
||||
# override checkedOutBooks form Library(parent) class
|
||||
def checkOutBook(self):
|
||||
#Set up a shopping cart to add multiple books
|
||||
print("You checked out Book 1")
|
||||
|
||||
#String Method
|
||||
def __str__ (self):
|
||||
return f'Welcome to: {super().__str__()}. The URL is: {self._url}'
|
||||
Reference in new issue
Block a user