Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Created lieur folder #40

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion projects/README.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
You should create a directory with your ONID similar to instructor's ONID at this location.
#Raymond Lieu, lieur
2 changes: 2 additions & 0 deletions projects/lieur/Assignment4/.idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions projects/lieur/Assignment4/.idea/Assignment4.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions projects/lieur/Assignment4/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions projects/lieur/Assignment4/.idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions projects/lieur/Assignment4/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

55 changes: 55 additions & 0 deletions projects/lieur/Assignment4/classroom_manager.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# CS362 Assignment 4
# Classroom Manager

#Student class
class Student:
def __init__(self, id, first_name, last_name):
self.id = id
self.first_name = first_name
self.last_name = last_name
self.assignments = []

def get_full_name(self):
return str(self.first_name + " " + self.last_name)

def submit_assignment(self, assignment):
self.assignments.append(assignment)


def get_assignments(self):
return self.assignments

def get_assignment(self, name):
for a in self.assignments:
if a.name == name:
return a
return

def get_average(self):
sum_grades = 0
total_assignments = 0
for a in self.assignments:
if a.grade != None:
sum_grades = sum_grades + a.grade
total_assignments = total_assignments + 1
average = sum_grades / total_assignments
return average

def remove_assignment(self, name):
for a in self.assignments:
if a.name == name:
self.assignments.remove(a)
return

#Assignment class
class Assignment:
def __init__(self, name, max_score):
self.name = name
self.max_score = max_score
self.grade = -1

def assign_grade(self, grade):
self.grade = grade
if grade >= self.max_score:
self.grade = None
return
83 changes: 83 additions & 0 deletions projects/lieur/Assignment4/test_classroom_manager.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
from unittest import TestCase
import classroom_manager


class TestStudent(TestCase):
def setUp(self):
self.student_id = 1
self.first_name = 'Raymond'
self.last_name = 'Lieu'
self.rl = classroom_manager.Student(self.student_id, self.first_name, self.last_name)
self.assignment1 = classroom_manager.Assignment('assignment1', 17)
self.assignment2 = classroom_manager.Assignment('assignment2', 19)

def test_student(self):
self.setUp()
self.assertEqual(self.rl.last_name, self.last_name)
self.assertEqual(self.rl.first_name, self.first_name)
self.assertEqual(self.rl.id, self.student_id)

def test_get_full_name(self):
self.setUp()
self.assertEqual(self.first_name + " " + self.last_name, self.rl.get_full_name())

def test_submit_assignment(self):
self.setUp()
self.assertEqual([], self.rl.assignments)
self.rl.submit_assignment(self.assignment1)
self.assertEqual(self.assignment1, self.rl.assignments[0])
self.rl.submit_assignment(self.assignment2)
self.assertEqual(self.assignment2, self.rl.assignments[1])

def test_get_assignments(self):
self.setUp()
self.assertEqual([], self.rl.get_assignments())
self.rl.submit_assignment(self.assignment1)
self.rl.submit_assignment(self.assignment2)
rl_assignments = [self.assignment1, self.assignment2]
self.assertEqual(rl_assignments, self.rl.get_assignments())

def test_get_assignment(self):
self.setUp()
self.assertEqual(None, self.rl.get_assignment('assignment1'))
self.rl.submit_assignment(self.assignment1)
self.assertEqual(self.assignment1, self.rl.get_assignment('assignment1'))
self.assertEqual(None, self.rl.get_assignment('assignment2'))


def test_get_average(self):
self.setUp()
self.assertEqual([], self.rl.get_assignments())
self.assignment1.assign_grade(14)
self.assignment2.assign_grade(16)
self.rl.submit_assignment(self.assignment1)
self.rl.submit_assignment(self.assignment2)
self.assertEqual(15, self.rl.get_average())

def test_remove_assignment(self):
self.setUp()
self.assertEqual(None, self.rl.get_assignment('assignment1'))
self.rl.submit_assignment(self.assignment1)
self.assertEqual(self.assignment1, self.rl.get_assignment('assignment1'))
self.rl.remove_assignment('assignment1')
self.assertEqual(None, self.rl.get_assignment('assignment1'))

class TestAssignment(TestCase):
def setUp(self):
self.max_score = 11
self.name = 'assignment7'
self.assignment7 = classroom_manager.Assignment(self.name, self.max_score)

def test_assignment(self):
self.setUp()
self.assertEqual(self.assignment7.name, self.name)
self.assertEqual(self.assignment7.max_score, self.max_score)
self.assertEqual(self.assignment7.grade, -1)

def test_assign_grade(self):
self.setUp()
self.assertEqual(self.assignment7.grade, -1)
self.assignment7.assign_grade(9)
self.assertEqual(self.assignment7.grade, 9)
self.assignment7.assign_grade(12)
self.assertEqual(None, self.assignment7.grade)
1 change: 1 addition & 0 deletions projects/lieur/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#Raymond Lieu, lieur
Loading