Title | SALst- course eleven2byte |
---|---|
Course | Software Design and Architecture |
Institution | University of Waterloo |
Pages | 3 |
File Size | 30.6 KB |
File Type | |
Total Downloads | 73 |
Total Views | 137 |
- course eleven2byte...
## # # ##
@file x.py @author Othman Mullick @brief x @date 05/07/2019
## @brief Imported packages and libraries. # @details Imports the _______ from StdntAllocTypes import * from AALst import * from DCapALst import * ## @brief ... # @details ... class SALst: s = [] ## @brief constructor # @details ... @staticmethod def __init__(): SALst.s = [] #set of StudentT #exception: none ## @brief ... # @param m string # @param i SInfoT String. @staticmethod def add(m, i): for d in SALst.s: if d == m: raise KeyError SALst.s.append(self.m, self.i) # adding to the seq syntax
## @brief ... # @param m string @staticmethod def remove(m): if m not in SALst.s: raise KeyError del SALst.s[m] # removing from the seq syntax # #Exception: KeyError ## @brief ... # @param m string # @return b bool @staticmethod def elm(m): b = 0 #check if (self.m, self.i) is in self.s ? return b #exception: none
## @brief ... # @param m string # @return i SInfoT @staticmethod def info(m): # what is this doing? #Exception: KeyError return o ## @brief ... # @param f SInfoT -> B # @return L ... @staticmethod def sort(f): # sorting what list? Any? # contains local functions: get_gpa and get_gpa(m, s) self.L = {} return L # below is correct implementation DISCLAIMER, NOT MY CODE. # def sort(f): # students = [] # sort_stdt = sorted(SALst.s, key=lambda x: SALst.s[x].gpa, reverse=True) # for t in sort_stdt: # if(f(SALst.s[t])): # students.append(t) # return students #exception: none ## @brief ... # @param f SInfoT -> B # @return seq sequence of string @staticmethod def average(f): # below is correct implementation DISCLAIMER, NOT MY CODE. # def average(f): # grades = [] # for x in SALst.s: # if(f(SALst.s[x])): # grades.append(SALst.s[x].gpa) # return sum(grades) / len(grades) seq = {} return seq #exception: none ## @brief ... # @param o SInfoT -> B # @return ret real @staticmethod def allocate(): #exception: RuntimeError # pretty much CalcModule.allocate() from A1. # THE BELOW CODE HAS BEEN TAKEN FROM A2, HAS ERRORS IMPLEMENTING ANONYMOUS FUNCTION LAMBDA # F = SALst.sort(lambda : t ! t:freechoice ^ t:gpa # 4:0)
# for all m in F # ch = SALst.info(m):choices # AALst.add stdnt(ch:next();m) # S = SALst.sort(#t ! :t:freechoice ^ t:gpa # 4:0) # for all m in S # ch = SALst.info(m):choices # alloc = False # while :alloc ^ :ch:end() # d = ch:next() # if AALst.num alloc(d) < DCapALst.capacity(d) # AALst.add stdnt(d;m) # alloc = True # if :alloc raise(RuntimeError)
''' Notes: #pushed to partner's repo '''...