Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions code/justin/contacts.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name,phone,state,spirit animal
justin,5558675309,MS,tomato
Jane, 1115558798, CA, turtle
Mick, 8887775498, PA, woodpecker
Sammy,31855963144, AR, hogger
Will,9876543216544,TY,Badger
bruce,8976541365,CA,dog
129 changes: 129 additions & 0 deletions code/justin/files.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
from hashlib import new


contacts=[]
keys=[]
ncontacts=[]
dic={}
p=1
new_entry = []

while True:
print('''\nWelcome to our contact database, please select from the following options:
To create new user enter "create":
To retrive an existing record enter "search":
To update an existing record enter "update":
To delete a record, enter "delete":
When finished, enter"done":''')
a = input("Enter: ")
if a.lower() == 'done':
False
break

elif a.lower() == 'create':
print('\nYou selected to enter a new user follow the commands')
n = input('enter a name: ')
new_entry.append(n)
ph = input('enter a phone number: ')
new_entry.append(ph)
st = input(f'enter {n}\'s state: ')
new_entry.append(st)
sa = input(f'enter {n}\'s spirit animal: ')
new_entry.append(sa)
j = ','.join(new_entry)
with open('contacts.csv', 'a') as file:
file.write(f'\n{j}')
elif a.lower() == 'search':
print('What user are you looking for?')
n = input('enter name: ')
with open('contacts.csv', 'r') as file:
lines = file.read().split('\n')
for l in lines:
if n.lower() in l.lower():
print(f'User {n} found: \n---------------------------------------------\n{l}')
print('---------------------------------------------')
elif a.lower() == 'update':
print('What contact do you want to update? ')
n = input('Enter name: ')
fin = open('contacts.csv', 'rt')
data = fin.read()
if n.lower() in data.lower():
print(f'User {n.title()} found')
for lines in data.split('\n'):
if n.lower() in lines.lower():
lines = lines.split(',')
# lines = ','.join(lines)
print(lines)
chg = input(f'What needs to change, name, phone, state or spirit animal? ')
if chg.lower() == 'name':
chg = input('Whats the new name? ')
data = data.replace(lines[0],chg)
fin.close()
fin = open('contacts.csv', 'wt')
fin.write(data)
fin.close()
elif chg.lower() == 'phone':
chg = input('Whats the new phone? ')
data = data.replace(lines[1], chg)
fin.close()
fin = open('contacts.csv', 'wt')
fin.write(data)
fin.close()
elif chg.lower() == 'state':
chg = input('Whats the new state? ')
data = data.replace(lines[2], chg)
fin.close()
fin = open('contacts.csv', 'wt')
fin.write(data)
fin.close()
elif chg.lower() == 'spirit animal':
chg = input('Whats the new spirit animal? ')
data = data.replace(lines[3], chg)
fin.close()
fin = open('contacts.csv', 'wt')
fin.write(data)
fin.close()
else:
print('not a valid option')
lines = (',').join(lines)
elif a.lower() == 'delete':
print('What contact do you want to delete? ')
n = input('Enter name: ')
fin = open('contacts.csv', 'rt')
data = fin.read()
if n.lower() in data.lower():
print(f'User {n.title()} found')
for num, lines in enumerate(data.split('\n')):
print(num, lines)
if n.lower() in lines.lower():
lines = lines.split(',')
# lines = ','.join(lines)
print(lines)
chg = input(f'Is this the entry you wish to delete?(y/n) ')





with open('contacts.csv', 'r') as file:
lines = file.read().split('\n')
for l in lines:
contacts.append(l.split(',')) #makes lists of contacts seperated by , inside of the contacts list
for c in contacts[0]: #header value for key:
keys.append(c) #puts the header value into a list by itself called keys
# contacts.append(new_entry)
while p < len(contacts):
a = dic.copy()
b = contacts[p].copy()
for k in keys: # k is contacts[0](headers.csv) iterated over
for c in b:
x=b.index(c)
b.pop(x)
a[k] = c
break
p+=1
ncontacts.append(a)

print(contacts)
print(ncontacts)

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added code/justin/mcapstone/images/M(1).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added code/justin/mcapstone/images/M(2).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added code/justin/mcapstone/images/M(3).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added code/justin/mcapstone/images/M(4).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added code/justin/mcapstone/images/M(5).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added code/justin/mcapstone/images/M(6).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added code/justin/mcapstone/images/M(7).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added code/justin/mcapstone/images/bg_star.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added code/justin/mcapstone/images/brk_bg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added code/justin/mcapstone/images/c1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added code/justin/mcapstone/images/c2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added code/justin/mcapstone/images/c3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added code/justin/mcapstone/images/c4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added code/justin/mcapstone/images/c5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added code/justin/mcapstone/images/c6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added code/justin/mcapstone/images/c7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added code/justin/mcapstone/images/c8.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added code/justin/mcapstone/images/ground.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added code/justin/mcapstone/images/honey_b.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added code/justin/mcapstone/images/karate(1).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added code/justin/mcapstone/images/mma.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added code/justin/mcapstone/images/moon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added code/justin/mcapstone/images/pdx_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added code/justin/mcapstone/images/pew.wav
Binary file not shown.
Binary file added code/justin/mcapstone/images/pink_gr.png
Binary file added code/justin/mcapstone/images/py.png
Binary file added code/justin/mcapstone/images/s1.png
Binary file added code/justin/mcapstone/images/s2.png
Binary file added code/justin/mcapstone/images/scene.png
Binary file added code/justin/mcapstone/images/strong.png
77 changes: 77 additions & 0 deletions code/justin/mcapstone/minicapstone.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import pygame
import random

pygame.init()
#creats screen and size
screen = pygame.display.set_mode((800, 600))

#background
background = pygame.image.load('images/scene.png')

#Title and icon
pygame.display.set_caption('New Game BOI')
icon = pygame.image.load('images/strong.png')
pygame.display.set_icon(icon)

#player
player_img = pygame.image.load('images/mma.png')
player_x = 100 #location of player on screen
player_y = 500
player_x_change = 0

#enemy
enemy_img = pygame.image.load('images/karate(1).png')
enemy_x = 700 #location of player on screen
enemy_y = 500
enemy_x_change = -0.3
enemy_y_change = 0

def player(x, y):
screen.blit(player_img, (x, y)) #blit means to draw

def enemy(x, y):
screen.blit(enemy_img, (x, y)) #blit means to draw


running = True
#infinte game loop to keep screen up
while running:

#((R,G,B))0-255
screen.fill((0, 0, 255))

#background image
screen.blit(background, (0, 0))

for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False

# checks if keystroke is right or left
if event.type == pygame.KEYDOWN: #any key is pressed
if event.key == pygame.K_LEFT:
player_x_change = -0.4
if event.key == pygame.K_RIGHT:
player_x_change = 0.4
if event.type == pygame.KEYUP:
if event.key == pygame.K_LEFT or event.key == pygame.K_RIGHT:
player_x_change = 0

player_x += player_x_change #creates the movement
enemy_x += enemy_x_change

if player_x <= 0: # this sets the boundaries for movement
player_x = 0
elif player_x >= 736: #736 is 800 -64 to account for object size
player_x = 736
# enemy boundaries
if enemy_x <= 0: # this sets the boundaries for movement
enemy_x_change = 0.3

elif enemy_x >= 736: #736 is 800 -64 to account for object size
enemy_x_change = -0.3


player(player_x, player_y)
enemy(enemy_x, enemy_y)
pygame.display.update() #always have to use this when updating the screen
Loading