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

Refactoriza metodos por implementaciones mas legibles #8

Merged
merged 1 commit into from
Oct 14, 2021
Merged
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
58 changes: 26 additions & 32 deletions Ejercicios/02-CodigoRepetido/CodigoRepetido-Ejercicio.st
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,6 @@ TestCase subclass: #CustomerBookTest
poolDictionaries: ''
category: 'CodigoRepetido-Ejercicio'!

!CustomerBookTest methodsFor: 'auxiliares' stamp: 'AS 10/11/2021 17:44:12'!
calcularLaDiferenciaDeTiempoCon: unBloque
"comment stating purpose of message"

| millisecondsBeforeRunning millisecondsAfterRunning |

millisecondsBeforeRunning := Time millisecondClockValue * millisecond.

unBloque value.

millisecondsAfterRunning := Time millisecondClockValue * millisecond.

^millisecondsAfterRunning-millisecondsBeforeRunning
! !


!CustomerBookTest methodsFor: 'tests' stamp: 'AS 10/11/2021 17:47:38'!
test01AddingCustomerShouldNotTakeMoreThan50Milliseconds

Expand Down Expand Up @@ -146,6 +130,22 @@ test08CanNotSuspendAnAlreadySuspendedCustomer
! !


!CustomerBookTest methodsFor: 'auxiliares' stamp: 'AS 10/11/2021 17:44:12'!
calcularLaDiferenciaDeTiempoCon: unBloque
"comment stating purpose of message"

| millisecondsBeforeRunning millisecondsAfterRunning |

millisecondsBeforeRunning := Time millisecondClockValue * millisecond.

unBloque value.

millisecondsAfterRunning := Time millisecondClockValue * millisecond.

^millisecondsAfterRunning-millisecondsBeforeRunning
! !


!CustomerBookTest methodsFor: 'auxiliares - assertion' stamp: 'AG 10/13/2021 18:32:58'!
verificarCantidadDeClientesActivosCon: unaCantidadDeActivos CantidadDeClientesSuspendidosCon: unaCantidadDeSuspendidos CantidadTotalDeClientes: unaCantidadDeClientes Para: unLibroDeClientes
self assert: unaCantidadDeActivos equals: unLibroDeClientes numberOfActiveCustomers.
Expand Down Expand Up @@ -189,21 +189,22 @@ initialize
suspended:= OrderedCollection new.! !


!CustomerBook methodsFor: 'customer management' stamp: 'AG 10/13/2021 18:33:58'!
!CustomerBook methodsFor: 'customer management' stamp: 'AS 10/13/2021 21:55:11'!
addCustomerNamed: aName

aName isEmpty ifTrue: [ self signalCustomerNameCannotBeEmpty ].
(self includesCustomerNamed: aName) ifTrue: [ self signalCustomerAlreadyExists ].

active add: aName ! !
active add: aName! !

!CustomerBook methodsFor: 'customer management' stamp: 'AG 10/13/2021 19:07:28'!
!CustomerBook methodsFor: 'customer management' stamp: 'AS 10/13/2021 20:33:18'!
removeCustomerNamed: aName
(((self removerCliente: aName de: active) = aName) or: ((self removerCliente: aName de: suspended) = aName)) ifTrue: [^aName].
^ NotFound signal
(self includesCustomerNamed: aName) ifFalse: [^NotFound signal].
self removerCliente: aName de: active.
self removerCliente: aName de: suspended.
! !

!CustomerBook methodsFor: 'customer management' stamp: 'NR 4/3/2019 10:14:26'!
!CustomerBook methodsFor: 'customer management' stamp: 'AS 10/13/2021 21:55:24'!
suspendCustomerNamed: aName

(active includes: aName) ifFalse: [^CantSuspend signal].
Expand Down Expand Up @@ -252,17 +253,10 @@ signalCustomerNameCannotBeEmpty
self error: self class customerCanNotBeEmptyErrorMessage ! !


!CustomerBook methodsFor: 'as yet unclassified' stamp: 'AG 10/13/2021 19:02:40'!
!CustomerBook methodsFor: 'auxiliar - removal' stamp: 'AS 10/13/2021 20:30:38'!
removerCliente: unCliente de: unaLista

1 to: unaLista size do:
[ :index |
unCliente = (unaLista at: index)
ifTrue: [
unaLista removeAt: index.
^ unCliente
]
].! !
(unaLista includes: unCliente) ifFalse: [^ NotFound ].
unaLista removeAt: (unaLista indexOf: unCliente).! !

"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!

Expand Down