Comp 110 Loan Case Study
description
Transcript of Comp 110 Loan Case Study
![Page 1: Comp 110 Loan Case Study](https://reader031.fdocuments.us/reader031/viewer/2022012917/568161b3550346895dd17d1b/html5/thumbnails/1.jpg)
COMP 110LOAN CASE STUDY
Instructor: Jason Carter
![Page 2: Comp 110 Loan Case Study](https://reader031.fdocuments.us/reader031/viewer/2022012917/568161b3550346895dd17d1b/html5/thumbnails/2.jpg)
2
CONTENTS Revisit, through non-graphical objects, concepts
illustrated in previous sections
![Page 3: Comp 110 Loan Case Study](https://reader031.fdocuments.us/reader031/viewer/2022012917/568161b3550346895dd17d1b/html5/thumbnails/3.jpg)
3
LOAN OBJECT
![Page 4: Comp 110 Loan Case Study](https://reader031.fdocuments.us/reader031/viewer/2022012917/568161b3550346895dd17d1b/html5/thumbnails/4.jpg)
4
PROPERTIES CLASSIFICATIONpublic class ABMISpreadsheet { double height;
public double getHeight() { return height; } public void setHeight(double newHeight) { height = newHeight; } double weight; public double getWeight() { return weight; } public void setWeight(double newWeight) { weight = newWeight; } public double getBMI() { return weight/(height*height); }}
Editable
Read-only
Independent
Dependent
![Page 5: Comp 110 Loan Case Study](https://reader031.fdocuments.us/reader031/viewer/2022012917/568161b3550346895dd17d1b/html5/thumbnails/5.jpg)
5
LOAN OBJECT
Editableand dependent
![Page 6: Comp 110 Loan Case Study](https://reader031.fdocuments.us/reader031/viewer/2022012917/568161b3550346895dd17d1b/html5/thumbnails/6.jpg)
6
1-WAY VS. 2-WAY DEPENDENCIES
bmi
weight
height
principal
monthly interest
yearly interest
![Page 7: Comp 110 Loan Case Study](https://reader031.fdocuments.us/reader031/viewer/2022012917/568161b3550346895dd17d1b/html5/thumbnails/7.jpg)
7
TOP-DOWN PROGRAMMING
Interface
Representation
Algorithm
Class
![Page 8: Comp 110 Loan Case Study](https://reader031.fdocuments.us/reader031/viewer/2022012917/568161b3550346895dd17d1b/html5/thumbnails/8.jpg)
8
BOTTOM-UP PROGRAMMING
Interface
Class
![Page 9: Comp 110 Loan Case Study](https://reader031.fdocuments.us/reader031/viewer/2022012917/568161b3550346895dd17d1b/html5/thumbnails/9.jpg)
9
LOAN OBJECT
![Page 10: Comp 110 Loan Case Study](https://reader031.fdocuments.us/reader031/viewer/2022012917/568161b3550346895dd17d1b/html5/thumbnails/10.jpg)
10
LOAN INTERFACE
public interface Loan {public int getPrincipal(); public void setPrincipal(int newValue);public int getYearlyInterest(); public void setYearlyInterest(int newVal); public int getMonthlyInterest(); public void setMonthlyInterest(int newVal);
}
![Page 11: Comp 110 Loan Case Study](https://reader031.fdocuments.us/reader031/viewer/2022012917/568161b3550346895dd17d1b/html5/thumbnails/11.jpg)
11
ALOAN REPRESENTATION
intprincipal getPrincipal()setPrincipal()
write read
getYearlyInterest()
getMonthlyInterest()
setYearlyInterest()
setMonhtlyInterest()
Representation = set of instance variables that stores object state
![Page 12: Comp 110 Loan Case Study](https://reader031.fdocuments.us/reader031/viewer/2022012917/568161b3550346895dd17d1b/html5/thumbnails/12.jpg)
12
LOAN OBJECT
Editableand dependent
Stored
Computed
![Page 13: Comp 110 Loan Case Study](https://reader031.fdocuments.us/reader031/viewer/2022012917/568161b3550346895dd17d1b/html5/thumbnails/13.jpg)
13
ALOAN ALGORITHM
intprincipal getPrincipal()setPrincipal()
write read
getYearlyInterest()
getMonthlyInterest()
setYearlyInterest()
setMonhtlyInterest()
F1
F2F2-1
F1-1
![Page 14: Comp 110 Loan Case Study](https://reader031.fdocuments.us/reader031/viewer/2022012917/568161b3550346895dd17d1b/html5/thumbnails/14.jpg)
14
SETTING AND GETTING THE STORED PROPERTY (EDIT)
intprincipal
intprincipal getPrincipal()setPrincipal()
public void setPrincipal(int newPrincipal) { }
public int getPrincipal() { }
![Page 15: Comp 110 Loan Case Study](https://reader031.fdocuments.us/reader031/viewer/2022012917/568161b3550346895dd17d1b/html5/thumbnails/15.jpg)
15
SETTING AND GETTING THE STORED PROPERTY
intprincipal
intprincipal getPrincipal()setPrincipal()
public void setPrincipal(int newPrincipal) { principal = newPrincipal;}
public int getPrincipal() { return principal;}
![Page 16: Comp 110 Loan Case Study](https://reader031.fdocuments.us/reader031/viewer/2022012917/568161b3550346895dd17d1b/html5/thumbnails/16.jpg)
16
SETTING AND GETTING COMPUTED PROPERTY (EDIT)
intprincipal
intprincipal getYearlyInterest()setYearlyInterest()
public void setYearlyInterest(int newInterest) { principal = (newInterest /INTEREST_RATE )*100;}
public int getYearlyInterest() { return principal*INTEREST_RATE/100;}
F1
F1-1
![Page 17: Comp 110 Loan Case Study](https://reader031.fdocuments.us/reader031/viewer/2022012917/568161b3550346895dd17d1b/html5/thumbnails/17.jpg)
17
SETTING AND GETTING COMPUTED PROPERTY
intprincipal
intprincipal getYearlyInterest()getYearlyInterest()
public void setYearlyInterest(int newInterest) { principal = newInterest/INTEREST_RATE*100;}
public int getYearlyInterest() { return principal*INTEREST_RATE/100;}
F1
F1-1
![Page 18: Comp 110 Loan Case Study](https://reader031.fdocuments.us/reader031/viewer/2022012917/568161b3550346895dd17d1b/html5/thumbnails/18.jpg)
18
SETTING AND GETTING COMPUTED PROPERTY (EDIT)
intprincipal
intprincipal
getMonthlyInterest()setMontlyInterest()
public void setMonthlyInterest(int newVal) { principal = 12*newVal/INTEREST_RATE*100;}
public int getMonthlyInterest() { return getYearlyInterest()/ 12;}
F2
F2-1
![Page 19: Comp 110 Loan Case Study](https://reader031.fdocuments.us/reader031/viewer/2022012917/568161b3550346895dd17d1b/html5/thumbnails/19.jpg)
19
SETTING AND GETTING COMPUTED PROPERTY (EDIT)
intprincipal
intprincipal
getMonthlyInterest()setMontlyInterest()
public void setMonthlyInterest(int newVal) { setYearlyInterest (newVal*12);}
public int getMonthlyInterest() { return getYearlyInterest()/12;}
F2
F2-1
![Page 20: Comp 110 Loan Case Study](https://reader031.fdocuments.us/reader031/viewer/2022012917/568161b3550346895dd17d1b/html5/thumbnails/20.jpg)
20
MODIFIED LOAN INTERFACE
public interface Loan {
public final int INTEREST_RATE = 6;
public int getPrincipal(); public void setPrincipal(int newValue);public int getYearlyInterest(); public void setYearlyInterest(int newVal); public int getMonthlyInterest(); public void setMonthlyInterest(int newVal);
}
![Page 21: Comp 110 Loan Case Study](https://reader031.fdocuments.us/reader031/viewer/2022012917/568161b3550346895dd17d1b/html5/thumbnails/21.jpg)
21
MIDDLE-OUT PROGRAMMING
Interface
Representation
Algorithm
Class
![Page 22: Comp 110 Loan Case Study](https://reader031.fdocuments.us/reader031/viewer/2022012917/568161b3550346895dd17d1b/html5/thumbnails/22.jpg)
22
ANOTHERLOAN REPRESENTATION
intyearlyInteres
tgetPrincipal()setPrincipal()
write read
getYearlyInterest()
getMonthlyInterest()
setYearlyInterest()
setMonhtlyInterest()
![Page 23: Comp 110 Loan Case Study](https://reader031.fdocuments.us/reader031/viewer/2022012917/568161b3550346895dd17d1b/html5/thumbnails/23.jpg)
23
CONVERSION ERRORS WITH PRINCIPAL REPRESENTATION
![Page 24: Comp 110 Loan Case Study](https://reader031.fdocuments.us/reader031/viewer/2022012917/568161b3550346895dd17d1b/html5/thumbnails/24.jpg)
24
NO CONVERSION ERRORS WITH YEARLY INTEREST REPRESENTATION
![Page 25: Comp 110 Loan Case Study](https://reader031.fdocuments.us/reader031/viewer/2022012917/568161b3550346895dd17d1b/html5/thumbnails/25.jpg)
25
LOANPAIRCar Loan Principal
Car Loan Yearly Interest
Car Loan Monthly Interest
House Loan Principal…
Car Loan
House Loan
Total Loan
Principal
Yearly Interest
Monthly Interest
![Page 26: Comp 110 Loan Case Study](https://reader031.fdocuments.us/reader031/viewer/2022012917/568161b3550346895dd17d1b/html5/thumbnails/26.jpg)
26
PRIMITIVE VS. OBJECT PROPERTIESCar Loan Principal
Car Loan Yearly Interest
Car Loan Monthly Interest
House Loan Principal…
Car Loan
House Loan
Total Loan
Principal
Yearly Interest
Monthly Interest
Primitive Properties
ObjectProperties
Reusing Loan!
![Page 27: Comp 110 Loan Case Study](https://reader031.fdocuments.us/reader031/viewer/2022012917/568161b3550346895dd17d1b/html5/thumbnails/27.jpg)
27
LOANPAIR INTERFACE (EDIT)
public interface LoanPair {
}
![Page 28: Comp 110 Loan Case Study](https://reader031.fdocuments.us/reader031/viewer/2022012917/568161b3550346895dd17d1b/html5/thumbnails/28.jpg)
28
LOANPAIR INTERFACE (EDIT)
public interface LoanPair { }
![Page 29: Comp 110 Loan Case Study](https://reader031.fdocuments.us/reader031/viewer/2022012917/568161b3550346895dd17d1b/html5/thumbnails/29.jpg)
29
TYPING OBJECTS
ALoan
AnotherLoan
Loan
![Page 30: Comp 110 Loan Case Study](https://reader031.fdocuments.us/reader031/viewer/2022012917/568161b3550346895dd17d1b/html5/thumbnails/30.jpg)
30
LOANPAIR INTERFACE
public interface LoanPair { public Loan getCarLoan(); public void setCarLoan( Loan newValue); public Loan getHouseLoan(); public void setHouseLoan( Loan newValue); public Loan getTotalLoan(); }
Actual ParametersALoan
AnotherLoan
![Page 31: Comp 110 Loan Case Study](https://reader031.fdocuments.us/reader031/viewer/2022012917/568161b3550346895dd17d1b/html5/thumbnails/31.jpg)
31
LOANPAIR INTERFACE: RESTRICTED
public interface LoanPair { public Loan getCarLoan(); public void setCarLoan( ALoan newValue); public Loan getHouseLoan(); public void setHouseLoan( ALoan newValue); public Loan getTotalLoan(); }
Actual ParametersALoan
AnotherLoan
![Page 32: Comp 110 Loan Case Study](https://reader031.fdocuments.us/reader031/viewer/2022012917/568161b3550346895dd17d1b/html5/thumbnails/32.jpg)
32
SPACE-EFFICIENT IMPLEMENTATION
Car Loan
House Loan
Total Loan
Independent
DependentComputed
Stored
![Page 33: Comp 110 Loan Case Study](https://reader031.fdocuments.us/reader031/viewer/2022012917/568161b3550346895dd17d1b/html5/thumbnails/33.jpg)
33
SPACE-EFFICIENT REPRESENTATION
Loan carLoan
getTotalLoan()
write read
getCarLoan ()
getHouseLoan()
setCarLoan()
setHouseLoan()
Loan houseLoan
![Page 34: Comp 110 Loan Case Study](https://reader031.fdocuments.us/reader031/viewer/2022012917/568161b3550346895dd17d1b/html5/thumbnails/34.jpg)
34
GETTER METHOD
Loan carLoan
getCarLoan ()
public Loan getCarLoan(){ return carLoan;
}
Accessing uninitialized object variable!
![Page 35: Comp 110 Loan Case Study](https://reader031.fdocuments.us/reader031/viewer/2022012917/568161b3550346895dd17d1b/html5/thumbnails/35.jpg)
35
DEFAULT VALUES FOR VARIABLESPrimitive Variables
double computedBMI;double weight;
Object Variables
Loan loan;
variables memory
0.00.0
null
computedBMI;weight;
loan;
Legal double values
Illegal Loan value
![Page 36: Comp 110 Loan Case Study](https://reader031.fdocuments.us/reader031/viewer/2022012917/568161b3550346895dd17d1b/html5/thumbnails/36.jpg)
36
GETTER METHOD
Loan carLoan
getCarLoan ()
public Loan getCarLoan(){ return carLoan;
}
ObjectEditor does not try to invoke methods if return
value is null!
![Page 37: Comp 110 Loan Case Study](https://reader031.fdocuments.us/reader031/viewer/2022012917/568161b3550346895dd17d1b/html5/thumbnails/37.jpg)
37
OBJECTEDITOR DISPLAY OF NULL
![Page 38: Comp 110 Loan Case Study](https://reader031.fdocuments.us/reader031/viewer/2022012917/568161b3550346895dd17d1b/html5/thumbnails/38.jpg)
38
HOW TO INITIALIZE OBJECT VARIABLE?
Loan carLoan
getCarLoan ()
public Loan getCarLoan(){ return carLoan;
}
Create instance of ALoan or AnotherLoan and assign to
variable
![Page 39: Comp 110 Loan Case Study](https://reader031.fdocuments.us/reader031/viewer/2022012917/568161b3550346895dd17d1b/html5/thumbnails/39.jpg)
39
INITIALIZATION OF OBJECT VARIABLES
Loan carLoan = new ALoan();
Loan houseLoan = new AnotherLoan();
Loan houseLoan = new Loan();
![Page 40: Comp 110 Loan Case Study](https://reader031.fdocuments.us/reader031/viewer/2022012917/568161b3550346895dd17d1b/html5/thumbnails/40.jpg)
40
INTERACTIVE VS. PROGRAMMED INSTANTIATION
new ALoan()
![Page 41: Comp 110 Loan Case Study](https://reader031.fdocuments.us/reader031/viewer/2022012917/568161b3550346895dd17d1b/html5/thumbnails/41.jpg)
41
ALOANPAIR
Loan carLoan = new Aloan()
getTotalLoan()
write read
getCarLoan ()
getHouseLoan()
setCarLoan()
setHouseLoan()
Loan houseLoan =
new AnotherLoan(
)
![Page 42: Comp 110 Loan Case Study](https://reader031.fdocuments.us/reader031/viewer/2022012917/568161b3550346895dd17d1b/html5/thumbnails/42.jpg)
42
GETTOTALLOAN()
Loan carLoan
getTotalLoan()
Loan houseLoan
public Loan getTotalLoan(){ return carLoan +
houseLoan; }
+ not defined for Loan!
![Page 43: Comp 110 Loan Case Study](https://reader031.fdocuments.us/reader031/viewer/2022012917/568161b3550346895dd17d1b/html5/thumbnails/43.jpg)
43
PROGRAMMER-DEFINED ADD ALGORITHM
public Loan add(Loan loan1, Loan loan2) {// create Loan instance// set one of its properties to sum of
corresponding properties of loan 1 and loan2// other properties are dependent and will be
set automatically// return Loan instance
}
![Page 44: Comp 110 Loan Case Study](https://reader031.fdocuments.us/reader031/viewer/2022012917/568161b3550346895dd17d1b/html5/thumbnails/44.jpg)
44
PROGRAMMER-DEFINED ADDpublic Loan add(Loan loan1, Loan loan2) {
Loan retVal = new ALoan();retVal.setPrincipal(loan1.getPrincipal() +
loan2.getPrincipal());return retVal;
}public Loan add(Loan loan1, Loan loan2) {
Loan retVal = new ALoan();retVal.setYearlyInterest(loan1.getYearlyInterest() +
loan2.getYearlyInterest());return retVal;
}public Loan add(Loan loan1, Loan loan2) {
Loan retVal = new ALoan();retVal.setMonthlyInterest(loan1.getMonthlyInterest() +
loan2.getMonthlyInterest());return retVal;
}
![Page 45: Comp 110 Loan Case Study](https://reader031.fdocuments.us/reader031/viewer/2022012917/568161b3550346895dd17d1b/html5/thumbnails/45.jpg)
45
RETURNING ANOTHERLOANpublic Loan add(Loan loan1, Loan loan2) {
Loan retVal = new AnotherLoan();retVal.setPrincipal(loan1.getPrincipal() +
loan2.getPrincipal());return retVal;
}public Loan add(Loan loan1, Loan loan2) {
Loan retVal = new AnotherLoan();retVal.setYearlyInterest(loan1.getYearlyInterest() +
loan2.getYearlyInterest());return retVal;
}public Loan add(Loan loan1, Loan loan2) {
Loan retVal = new AnotherLoan();retVal.setMonthlyInterest(loan1.getMonthlyInterest() +
loan2.getMonthlyInterest());return retVal;
}
![Page 46: Comp 110 Loan Case Study](https://reader031.fdocuments.us/reader031/viewer/2022012917/568161b3550346895dd17d1b/html5/thumbnails/46.jpg)
46
COMBINING OBJECT CREATION AND INITIALIZATIONpublic Loan add(Loan loan1, Loan loan2) {
Loan retVal = new ALoan();retVal.setPrincipal(loan1.getPrincipal() +
loan2.getPrincipal());return retVal;
}
public Loan add(Loan loan1, Loan loan2) {return new ALoan(loan1.getPrincipal() +
loan2.getPrincipal()));}
Object Creation Object Initialization
Combined creation and initialization
![Page 47: Comp 110 Loan Case Study](https://reader031.fdocuments.us/reader031/viewer/2022012917/568161b3550346895dd17d1b/html5/thumbnails/47.jpg)
47
ADDING CONSTRUCTOR IN ALOAN
intprincipal getPrincipal()setPrincipal()
write read
getYearlyInterest()
getMonthlyInterest()
setYearlyInterest()
setMonhtlyInterest()
ALoan()
initialize
Constructor
![Page 48: Comp 110 Loan Case Study](https://reader031.fdocuments.us/reader031/viewer/2022012917/568161b3550346895dd17d1b/html5/thumbnails/48.jpg)
48
CONSTRUCTOR VS. REGULAR METHODpublic class ALoan implements Loan{
int principal;
public int getPrincipal() { return principal;}public void setPrincipal(int newVal) { principal = newVal;}…
}
public ALoan(int initPrincipal) {setPrincipal(initPrincipal);
}
Missing return type name
Combined return type and method name
public ALoan ALoan(int initPrincipal) {
setPrincipal(initPrincipal);}
Not a constructor!
![Page 49: Comp 110 Loan Case Study](https://reader031.fdocuments.us/reader031/viewer/2022012917/568161b3550346895dd17d1b/html5/thumbnails/49.jpg)
49
INSTANTIATION REQUIRES PARAMETERS
new ALoan(10000)
new ALoan()
![Page 50: Comp 110 Loan Case Study](https://reader031.fdocuments.us/reader031/viewer/2022012917/568161b3550346895dd17d1b/html5/thumbnails/50.jpg)
50
CONSTRUCTOR Method that constructs a new object based on
its parameters new ALoan(10000)
Actually, just initializes object Object constructed by Java Front-end to object construction Cannot be declared in interface Chooses implementation
![Page 51: Comp 110 Loan Case Study](https://reader031.fdocuments.us/reader031/viewer/2022012917/568161b3550346895dd17d1b/html5/thumbnails/51.jpg)
51
MULTI-PARAMETER CONSTRUCTOR
public ALoanPair (Loan initCarLoan, Loan initHouseLoan) {setCarLoan(initCarLoan);setHouseLoan(initHouseLoan);
}
new ALoanPair(new ALoan(10000), new ALoan(10000))
Usually as many constructor parameters as are required to initialize independent instance variables
![Page 52: Comp 110 Loan Case Study](https://reader031.fdocuments.us/reader031/viewer/2022012917/568161b3550346895dd17d1b/html5/thumbnails/52.jpg)
52
DEFAULT CONSTRUCTORpublic class ALoan implements Loan{
int principal;
public int getPrincipal() { return principal;}public void setPrincipal(int newVal) { principal = newVal;}…
}
public ALoan();}
Default
Inserted in object code, not in source code
new ALoan()
Invoking the default constructor
![Page 53: Comp 110 Loan Case Study](https://reader031.fdocuments.us/reader031/viewer/2022012917/568161b3550346895dd17d1b/html5/thumbnails/53.jpg)
53
PROGRAMMER-DEFINED ADD
public Loan getTotalLoan(){ return ALoan.add(houseLoan, carLoan);
}
public static Loan add(Loan loan1, Loan loan2) { return new ALoan(loan1.getPrincipal() + loan2.getPrincipal()));}
Instance Method
Class Method
Accesses instance variables
Access no instance variable
![Page 54: Comp 110 Loan Case Study](https://reader031.fdocuments.us/reader031/viewer/2022012917/568161b3550346895dd17d1b/html5/thumbnails/54.jpg)
54
POLYMORPHIC METHODS
public static Loan add(Loan loan1, Loan loan2) { return new ALoan(loan1.getPrincipal() + loan2.getPrincipal()));}
Methods that take actual parameters of different
typesALoan
instanceAnotherLoan
instance
Actual parameters of different types
![Page 55: Comp 110 Loan Case Study](https://reader031.fdocuments.us/reader031/viewer/2022012917/568161b3550346895dd17d1b/html5/thumbnails/55.jpg)
55
NON-POLYMORPHIC METHODS
public static Loan add(ALoan loan1, ALoan loan2) { return new ALoan(loan1.getPrincipal() + loan2.getPrincipal()));}
public static Loan add(AnotherLoan loan1, AnotherLoan loan2) { return new ALoan(loan1.getPrincipal() + loan2.getPrincipal()));}
public static Loan add(ALoan loan1, AnotherLoan loan2) { return new ALoan(loan1.getPrincipal() + loan2.getPrincipal()));}
Code duplication!
![Page 56: Comp 110 Loan Case Study](https://reader031.fdocuments.us/reader031/viewer/2022012917/568161b3550346895dd17d1b/html5/thumbnails/56.jpg)
56
OVERLOADING VS. POLYMORPHISM
public static Loan add(Loan loan1, Loan loan2) { return new ALoan(loan1.getPrincipal() + loan2.getPrincipal()));}public static Loan add(ALoan loan1, ALoan loan2) { return new ALoan(loan1.getPrincipal() + loan2.getPrincipal()));}public static Loan add(ALoan loan1, AnotherLoan loan2) { return new ALoan(loan1.getPrincipal() + loan2.getPrincipal()));}
Polymorphism Overloading
add (new ALoan(10000), new ALoan(5000));add (new ALoan(10000), new
AnotherLoan(5000));
![Page 57: Comp 110 Loan Case Study](https://reader031.fdocuments.us/reader031/viewer/2022012917/568161b3550346895dd17d1b/html5/thumbnails/57.jpg)
57
PRIMITIVE VS. OBJECT TYPEStypes
Primitive types
Object types
double int
ABMICalculator ABMISpreadsheet
ALoan
BMISpreadsheet
Classes
Interfaces
type = set of operations
AnotherLoan
Loan
![Page 58: Comp 110 Loan Case Study](https://reader031.fdocuments.us/reader031/viewer/2022012917/568161b3550346895dd17d1b/html5/thumbnails/58.jpg)
58
STRUCTURED VS. ATOMIC TYPEStypes
Primitive types
Structured types
double int
ABMICalculator ABMISpreadsheet
ALoan
BMISpreadsheet
Classes
Interfaces
Instances of structured type decomposed into one or more smaller values
AnotherLoan
Loan
![Page 59: Comp 110 Loan Case Study](https://reader031.fdocuments.us/reader031/viewer/2022012917/568161b3550346895dd17d1b/html5/thumbnails/59.jpg)
59
LOAN INTERFACE
public interface Loan {public int getPrincipal(); public void setPrincipal(int newValue);public int getYearlyInterest(); public void setYearlyInterest(int newVal); public int getMonthlyInterest(); public void setMonthlyInterest(int newVal);
}
![Page 60: Comp 110 Loan Case Study](https://reader031.fdocuments.us/reader031/viewer/2022012917/568161b3550346895dd17d1b/html5/thumbnails/60.jpg)
60
ALOAN REPRESENTATION
intprincipal getPrincipal()setPrincipal()
write read
getYearlyInterest()
getMonthlyInterest()
setYearlyInterest()
setMonhtlyInterest()
![Page 61: Comp 110 Loan Case Study](https://reader031.fdocuments.us/reader031/viewer/2022012917/568161b3550346895dd17d1b/html5/thumbnails/61.jpg)
61
ANOTHERLOAN REPRESENTATION
intyearlyInteres
tgetPrincipal()setPrincipal()
write read
getYearlyInterest()
getMonthlyInterest()
setYearlyInterest()
setMonhtlyInterest()
![Page 62: Comp 110 Loan Case Study](https://reader031.fdocuments.us/reader031/viewer/2022012917/568161b3550346895dd17d1b/html5/thumbnails/62.jpg)
62
PHYSICAL VS. LOGICAL STRUCTURE
ALoan Instance int
principal;
Physical
ALoan Instance int
Principal;
Logical
int
int
YearlyInterest
;
MonthlyInterest;
![Page 63: Comp 110 Loan Case Study](https://reader031.fdocuments.us/reader031/viewer/2022012917/568161b3550346895dd17d1b/html5/thumbnails/63.jpg)
63
LOANPAIR INTERFACE
public interface LoanPair {public Loan getCarLoan();public void setCarLoan(Loan newValue);
public Loan getHouseLoan(); public void setHouseLoan(Loan newValue); public Loan getTotalLoan();
}
![Page 64: Comp 110 Loan Case Study](https://reader031.fdocuments.us/reader031/viewer/2022012917/568161b3550346895dd17d1b/html5/thumbnails/64.jpg)
64
ALOANPAIR
Loan carLoan
getTotalLoan()
write read
getCarLoan ()
getHouseLoan()
setCarLoan()
setHouseLoan()
Loan houseLoan
![Page 65: Comp 110 Loan Case Study](https://reader031.fdocuments.us/reader031/viewer/2022012917/568161b3550346895dd17d1b/html5/thumbnails/65.jpg)
65
PHYSICAL VS. LOGICAL STRUCTURE
ALoanPair Instance
LoancarLoan;
Physicalint
principal;
Loan intprincipal
;houseLoan;
Variable name
Class or primitive type
of value stored in variable
![Page 66: Comp 110 Loan Case Study](https://reader031.fdocuments.us/reader031/viewer/2022012917/568161b3550346895dd17d1b/html5/thumbnails/66.jpg)
66
PHYSICAL VS. LOGICAL STRUCTURE
ALoanPair Instance LoanCarLoan;
Logical
Loan
Loan
TotalLoan;
HouseLoan;
intPrincipal
;
int
int
YearlyInterest
;
MonthlyInterest;
Property name
Class or primitive type
of property value