EECS2030 Advanced Object-Oriented Programming
Review Tutorials on OOP in Java -Building an Apple Refurbished Store App
Instructor: Jackie WangCreated: Fall 2021
WZI)
a
EECS2030-F21 Lectures Site https://www.eecs.yorku.ca/~jackie/teaching/lectures/index.html#EECS2030_F21Resources - EECS1022-W21 Lecture Recordings - Review Slides on OOP (cross-referenced throughout the current tutorial series) + Weeks 7, 8, 9 of EECS1022-W21 lecture recordings - Written Notes: + Inferring Classes/Methods from JUnit Tests + Declaring and Manipulating Reference-Typed, Multi-Valued Attributes - Background Slides on Elementary Programming, Conditionals, Loops + Weeks 1 to 6 of EECS1022-W21 lecture recordings - EECS1022-W21 Tutorials + Week 1: Eclipse Work Environment + Week 2c, 2d, 2e: Debugger + Weeks 2, 3: Conditionals + Weeks 4, 5: Loops and Arrays + Weeks 6, 7, 8: OOP + Weeks 10, 11: Two-Dimensional Arrays + Week 12: Java API - ArrayList vs. Hashtable - Github (educational account; private repositories)
E]
D. D. D. → step over, into , out= -
ooo-
. u
- u -
•
Tips for Studying this Tutorial Series - Type with me (watch out for spellings). - Pay extra attention to visualizations, tracing, and debugger. - Pause when you need to think. - Replay if necessary. - You will be required to submit the code.
0.
☒I80
.
console_apps
model
junit_tests
use
use
Separation of Concerns
- Classes & Methods- Methods * constructors * accessors: return statements * mutators: no return statements * containing no print statements
- Expected vs. Actual Values- Methods * calling methods from model * assertions * containing no print statements
- main method (entry point of execution) * reading inputs from keyboard * calling methods from model * producing outputs to console (print) * containing no return statements
↳unit testing .
=.
⑤ ..
=: ↳¥d nails
⇒% →
c-
I.
.
'
Sanne.= crotch
. = &→ ☐
Problem: A Refurbished Shop of Apple Products
- https://www.apple.com/ca/shop/refurbished- Product: + unique serial number (e.g., F9FDN4NKQ1GC) + model, finish, storage (e.g., iPad Pro 12.9, Space Grey, 1TB) + cellular connectivity?, original price, discount value- Entry: a pair of serial number and its associated product- Refurbished Store: a collection of entries + add/remove entries + get the stored collection of entries/products + get the associated product/model of a serial number + get serial numbers of products satisfying some criteria
c-%⇒
⇐ twotpadshavethesamesn . g±y-
.
E- -
→
e-
Computer MemoryVisualization: Object CreationsTemplate Definition
Instance Creation
Product@29444d75
Product@29444d75
Product@2280cdac
Product@2280cdac
fdsep __=p2(are they referring tosameobj?trip
. !=p2 .✓
i
..
attributes p→¥pz→¥" .
① .
(sWch€ ✓ nulli.
of runtime null•
☐✓ objects) ② P pz false
0.0°
mm
PadP9 pgq.ae↳
0.0
✓
g-object • "Hadron.9"
null0
false→ 1289.00
object being ⑥ •
☐0.0
Created . ② g- ODD i.
Visualization: Method Calls
JUnit Test Case
Template DefinitionProduct65¥ : -
.
> im. iPad For.9-
.
PÑ Space Grey- S - 1000 ✓
/
- c. ⑦ - --
pfnish=⇐
for:¥j!:*" #¥¥ydp. 220.00
Too X-p Too
✓ . To TT
☒
-1✓ ⇐ xp I
-
a- xp
o. =D price: B-☒
0 *§P•-
o
Product
Product
Value loprfñg aliasing .addressd- and 0×49"
objectstore 0¥15 0×4972
Case I. Primitive Variables tmnatiple PZ Plvariables.
✓Tnt I = 23-5 23 23 P↳d×Zk's✓ Tnt j = I } I J
= ↳
copy value stared ñ I tophI0xÉazCase 2 : Reference Variable
✓Product # = need Products ,Product p2=n@ Products :→
p2= platy copy addressstoredñpl to p2
Visualization: Aliasing
Template Definition
JUnit Test Case
Product Product Product
context obj. ✓
=D-
- -
e.→ Entry and e.productsin. "F9☐N4 ""
D' °
? d①"#both preference same obj .p.
e. product =p : P""**÷÷): akas-mg-b.tn pz ande.product✓
-p ref.
same✗e Ts obj.↳v.v.fome.pro#.t*h-E........e.pwdut--Pij2at-s-GPZ-bfu-ngybothpande.pwdu-ik-xp.id-t.rs#→
rep.sameobj.ieXe i¥dAiÑo m.ipadpnox.gl?Z#m?-.padf-rP----~m..-padG
f. Golde.product=p -3 s. yooo s. 64 §. 7€
→Xe Xe c.c. True c.c. false c.c. false
O.p. 1709.00 O-P. 649.00 O.p. 649.00d.V. 220.00 d.V. 100-00 d.V. ④
Visualization: Adding Entries
JUnit Test Case
Template Definition
Productm.f.s.c.c.o.p.d.v.
Productm.f.s.c.c.o.p.d.v.
Productm.f.s.c.c.o.p.d.v.
Entrysnp.
Entrysnp.
Entrysnp.
F9FDN… C9FZN… 7YM4P…
iPad Pro 12.9 iPad Air iPad Pro 10.5Space Grey Gold null1000 64 0true falsefalse1709.00 649.00
0.0929.00
100.00220.00
aliasing : elsrs.es-10], -
→→rs¥=¥ se, rs.es-lrs.me]=el;ns.gettnslkd -
rs.ne.eu ,=
→5→
✗ xpzrs.es-4]=*;☐E)
☐ → → M④ r±e++s
-
= - → Is
¥ &= - - ¥ ¥¥¥¥É- Refurbishedstore oiasxentries → I I
-
- I¥ :*, es-ot-rs.es#e***i&n&.GiEiimH"P -- - L#• < **→
> <
78¥
÷
a
rs.getPrivateEntriesArray()[2].getProduct().getModel().equals(“iPad Pro 10.5”)
Analyzing Dot Notation
Product String1Entry]
Entry
-
.
=-
furbishedstore
Productm.f.s.c.c.o.p.d.v.
Productm.f.s.c.c.o.p.d.v.
Productm.f.s.c.c.o.p.d.v.
Entrysnp.
Entrysnp.
Entrysnp.
F9FDN… C9FZN… 7YM4P…
iPad Pro 12.9 iPad Air iPad Pro 10.5Space Grey Gold null1000 64 0true falsefalse1709.00 649.00
0.0929.00
100.00220.00
e1
p1 p2
* **
***
entriesnoe
rs RefurbishedStore
0 1 2 3 43
Visualization of a Refurbished Store with 3 Entries
→.
IEEE →↳ t
Productm.f.s.c.c.o.p.d.v.
Productm.f.s.c.c.o.p.d.v.
Productm.f.s.c.c.o.p.d.v.
Entrysnp.
Entrysnp.
Entrysnp.
F9FDN… C9FZN… 7YM4P…
iPad Pro 12.9 iPad Air iPad Pro 10.5Space Grey Gold Silver1000 64 256true falsefalse1709.00 649.00
270.00929.00
100.00220.00
e1
p1 p2
* **
***
entriesnoe
rs RefurbishedStore
0 1 2 3 43
RefurbishedStore Class: getSpaceGreyOrPro()0 1What is the mm^# of products satisfying ☒⇒⇒oµpp?%%nt_↳⑧ the search criteria?
→.
→• -¥- % , ⑧
met
-
¥¥↳tee
.
Aunt
→It →→ sns SHE]↳ t
indices -10J indices-11]
22snsl-i-rs.entrtesf-ndiies-OJJ.GS?n%11--rs#-eIadicesE-i] . getstk)