diff --git a/Project 1/Printed Version.pdf b/Project 1/OLD Printed Version.pdf similarity index 100% rename from Project 1/Printed Version.pdf rename to Project 1/OLD Printed Version.pdf diff --git a/Project 1/Solitaire.py b/Project 1/Solitaire.py index 254f97e..fe0334e 100644 --- a/Project 1/Solitaire.py +++ b/Project 1/Solitaire.py @@ -1,19 +1,28 @@ -from Deck import Deck -""" -Defines the Solitaire game logic. Contains methods to play the game by dealing cards, removing cards based on game rules, and checking for a win condition. +###################################### +# DCS 229 -- Unfair Solitaire +# Defines the Solitaire game logic. Contains methods to play the game by dealing cards, removing cards based on game rules, and checking for a win condition. +# Name: Benjamin Adovasio +# Resources Used: Fran +########################################## + +from Deck import Deck -Important Note: The prints in this file only run when this file is ececuted directly. This file should not be executed directly normally. -""" class Solitaire: def __init__(self): self.deck = Deck() self.face_up = [] #List to hold face-up cards. + ''' + deals cards until there are four face-up cards or the deck is empty. + ''' def deal_until_four(self): while len(self.face_up) < 4 and self.deck.number_of_cards() > 0: self.face_up.append(self.deck.deal()) #Deals cards until there are four face-up cards. + ''' + removes the last four cards if they are all the same suit. Returns True if cards were removed, False otherwise. + ''' def remove_four_same_suit(self) -> bool: if len(self.face_up) < 4: return False #Not enough cards to remove four of the same suit. @@ -27,6 +36,9 @@ class Solitaire: return False + ''' + removes the inner two cards if the first and last card of the last four cards are the same suit. Returns True if cards were removed, False otherwise. + ''' def remove_inner_two(self) -> bool: if len(self.face_up) < 4: return False #Not enough cards to remove inner two cards. @@ -38,13 +50,20 @@ class Solitaire: return False + + ''' + Attempts to remove cards based on game rules. + ''' def remove_all_possible(self): removed = True while removed and len(self.face_up) >= 4: removed = self.remove_four_same_suit() if not removed: removed = self.remove_inner_two() # Attempts to remove cards based on game rules. - + + ''' + plays the game by shuffling the deck, dealing cards, removing cards based on game rules, and checking for a win condition. + ''' def playGame(self) -> bool: self.deck.shuffle() self.face_up = [] diff --git a/Project 2/Card.py b/Project 2/Card.py index 3052a85..e81bf42 100644 --- a/Project 2/Card.py +++ b/Project 2/Card.py @@ -1,3 +1,11 @@ +###################################### +# DCS 229 -- Project 2 +# This is the Card.py file, which defines the Card class used in the Solitaire game. The Card class represents a playing card with a suit and value, and includes methods to retrieve the suit and value, as well as a string representation of the card. +# Date: 04/01/2026 +# Name: Benjamin Adovasio +# Resources Used: Fran +########################################## + class Card: """ Represents a playing card with a suit and value. diff --git a/Project 2/Deck.py b/Project 2/Deck.py index 21f8a1b..f63a50e 100644 --- a/Project 2/Deck.py +++ b/Project 2/Deck.py @@ -1,3 +1,11 @@ +###################################### +# DCS 229 -- Project 2 +# This is the Deck.py file, which defines the Deck class used in the Solitaire game. The Deck class represents a standard 52-card deck, and includes methods to shuffle the deck, deal cards, and check the number of remaining cards. +# Date: 04/01/2026 +# Name: Benjamin Adovasio +# Resources Used: Fran +########################################## + import random from Card import Card """ diff --git a/Project 2/Printed Version.pdf b/Project 2/OLD Printed Version.pdf similarity index 100% rename from Project 2/Printed Version.pdf rename to Project 2/OLD Printed Version.pdf diff --git a/Project 2/Solitaire.py b/Project 2/Solitaire.py index 254f97e..4046adc 100644 --- a/Project 2/Solitaire.py +++ b/Project 2/Solitaire.py @@ -1,19 +1,28 @@ -from Deck import Deck -""" -Defines the Solitaire game logic. Contains methods to play the game by dealing cards, removing cards based on game rules, and checking for a win condition. +###################################### +# DCS 229 -- Project 2 +# Defines the Solitaire game logic. Contains methods to play the game by dealing cards, removing cards based on game rules, and checking for a win condition. +# Name: Benjamin Adovasio +# Resources Used: Fran +########################################## + +from Deck import Deck -Important Note: The prints in this file only run when this file is ececuted directly. This file should not be executed directly normally. -""" class Solitaire: def __init__(self): self.deck = Deck() self.face_up = [] #List to hold face-up cards. + ''' + deals cards until there are four face-up cards or the deck is empty. + ''' def deal_until_four(self): while len(self.face_up) < 4 and self.deck.number_of_cards() > 0: self.face_up.append(self.deck.deal()) #Deals cards until there are four face-up cards. + ''' + removes the last four cards if they are all the same suit. Returns True if cards were removed, False otherwise. + ''' def remove_four_same_suit(self) -> bool: if len(self.face_up) < 4: return False #Not enough cards to remove four of the same suit. @@ -27,6 +36,9 @@ class Solitaire: return False + ''' + removes the inner two cards if the first and last card of the last four cards are the same suit. Returns True if cards were removed, False otherwise. + ''' def remove_inner_two(self) -> bool: if len(self.face_up) < 4: return False #Not enough cards to remove inner two cards. @@ -38,6 +50,9 @@ class Solitaire: return False + ''' + Attempts to remove cards based on game rules. + ''' def remove_all_possible(self): removed = True while removed and len(self.face_up) >= 4: @@ -45,6 +60,9 @@ class Solitaire: if not removed: removed = self.remove_inner_two() # Attempts to remove cards based on game rules. + ''' + plays the game by shuffling the deck, dealing cards, removing cards based on game rules, and checking for a win condition. + ''' def playGame(self) -> bool: self.deck.shuffle() self.face_up = [] diff --git a/Project 2/main.py b/Project 2/main.py index f680be4..bd8ed39 100644 --- a/Project 2/main.py +++ b/Project 2/main.py @@ -1,6 +1,11 @@ -""" -This is the main file that should be called to run the simulation. -""" +###################################### +# DCS 229 -- Unfair Solitaire +# This is the main.py file, which contains the main function to run the simulation. +# Date: 04/01/2026 +# Name: Benjamin Adovasio +# Resources Used: Fran +########################################## + from Solitaire import Solitaire diff --git a/Project 2/utilities.py b/Project 2/utilities.py index 9b7effd..ce7923e 100644 --- a/Project 2/utilities.py +++ b/Project 2/utilities.py @@ -1,24 +1,37 @@ -""" -Reo -""" +###################################### +# DCS 229 -- Project 2 +# This is the utilities.py file, which contains utility functions for the Solitaire game. +# Date: 04/01/2026 +# Name: Benjamin Adovasio +# Resources Used: Fran +########################################## + from __future__ import annotations from Card import Card -def sum_cards_iter(cards: list[Card]) -> int: +''' +Added for project 2: Created a function to sum a list of Card objects using iteration. +''' +def sum_cards_iter(cards: list[Card]) -> int: #start total at 0 total = 0 #start total at 0 for card in cards: - total = total + card + total = total + card #Adds the value of each card to the total using iteration. return total -#Added for project 2: Created a function to sum a list of Card objects using iteration. -def sum_cards_recursive(cards: list[Card]) -> int: +''' +Added for project 2: Created a function to sum a list of Card objects using recursion. +''' +def sum_cards_recursive(cards: list[Card]) -> int: #start total at 0 if cards == []: #Base case - return 0 - return cards[0] + sum_cards_recursive(cards[1:]) + return 0 #If the list of cards is empty, return 0. + return cards[0] + sum_cards_recursive(cards[1:]) #Adds the value of the first card to the sum of the remaining cards using recursion. #Recursive case -#Added for project 2: Created a function to sum a list of Card objects using recursion. + +''' +Added for project 2: Example tests given +''' def test_sum_cards(): cards = [ Card("diamond", 5), @@ -28,4 +41,3 @@ def test_sum_cards(): ] assert sum_cards_iter(cards) == 21 assert sum_cards_recursive(cards) == 21 -#Added for project 2: Example tests given \ No newline at end of file