FIT1051 Lecture 10: Week 10

324 views2 pages
Week 10
Monday, 7 May 2018
10:16 AM
Changing something:
1. Decide which class needs to be changed first. Decide what needs to be change.
2. Try not to change what is already in the code. Working code is gold. Changing it may cause it to
not work.
Even if the code is horrid, it is working. Rewriting it completely may cause errors.
*Make as few changes as possible
3. Object orientation - all classes must be understood.
How to shut down other classes and only think of the interface [developer]
As a developer you only need to understand the classes you are working on, and interfaces of
other classes.
As a 1051 student, you need to understand everything
//INSTANCE VARIABLES
private String name;
private Date dob; //This is a reference
private int numberOfLimbs;
private int numberOfEyes;
private boolean canFly;
private Food favouriteFood; //Reference
private TemperamentEnum temperature;
private double lifetimeFeed; //set to 0 from beginning since monster has not eaten when
first created
private TemperamentEnum temperament; //must be aggressive, passive or undetermined or null
(default)
Will check if it's one of the values or else it'll cause a compile error.
No guardian code because java will reject everything that is not one of the 3 values
private static int numMonstersInstantiated;
"That instance monster's name"
How many times has a constructor been used to create a monster.
Every monster will be born with the constructors instantiated.
By making it static:
Only 1 in memory
All of the objects can see it, therefore constructor can up it by 1.
Create 2, it'll up by 2.
Keeps count of it.
HOWEVER, it does not keep count of monsters in the zoo, because it does not decrease when a
monster is deleted.
Therefore only counts the number of monsters created.
Min age & Max age
find more resources at oneclass.com
find more resources at oneclass.com
Unlock document

This preview shows half of the first page of the document.
Unlock all 2 pages and 3 million more documents.

Already have an account? Log in

Document Summary

Changing something: decide which class needs to be changed first. Decide what needs to be change: try not to change what is already in the code. Changing it may cause it to not work. Even if the code is horrid, it is working. *make as few changes as possible: object orientation - all classes must be understood. How to shut down other classes and only think of the interface [developer] As a developer you only need to understand the classes you are working on, and interfaces of other classes. As a 1051 student, you need to understand everything. Will check if it"s one of the values or else it"ll cause a compile error. No guardian code because java will reject everything that is not one of the 3 values private static int nummonstersinstantiated; How many times has a constructor been used to create a monster. Every monster will be born with the constructors instantiated.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents