Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Daniel Lawson
- 9/22/2016
- 17.
- A constructor is used to initialize the fields of a class when the instance is createed
- 18.
- First a constructor is not supposed to be void (the header should be public Point(initialX, initial)
- and y they created and assigned the values to a new integers called x and y in the following constructor Instead of assigning x and y to initialx and initial y to the fields x
- 19.
- public class Name{
- private String firstName;
- private String lastName;
- private char middleInitial;
- public Name(String f, char m, String l){
- firstName = f;
- MiddleInitial = m;
- lastName = l;
- }
- public String getNormalOrder(){
- return (firstName + " " +middleInitial +". " + lastName);
- }
- public String getReverseOrder(){
- return (lastName + ", " + firstName + " " +middleInitial +"." );
- }
- }
- 20.
- this is used to speficy what you are refering to.This is used to refer to a field instead of a variable. This is also used to call a method that you are in and with the same or different parameters
- 21.
- Public Point(Point p){
- this.x = p.getX();
- this.y = p.getX();
- }
- 22.
- Abstraction allows the client to know how to use something without knowing how it internally works.
- 23.
- Public allows things to be accessed outside the program while private does not. You should make a class's fields private.
- 24.
- By uses a accessor method to see the values of the fields
- 25.
- public void setX(int x){
- this.x = x;
- }
- public void setY(int y){
- this.y = y;
- }
- 26.
- public class Name{
- private String firstName;
- private String lastName;
- private char middleInitial;
- public Name(String f, char m, String l){
- firstName = f;
- MiddleInitial = m;
- lastName = l;
- }
- public String getNormalOrder(){
- return (firstName + " " +middleInitial +". " + lastName);
- }
- public String getReverseOrder(){
- return (lastName + ", " + firstName + " " +middleInitial +"." );
- }
- public String getLastName(){
- return lastName();
- }
- public String getFirstName(){
- return firstName();
- }
- public char getMiddleInitial(){
- return middleInitial();
- }
- }
- 27.
- public void setFirstName(String firstName){
- this.firstName = firstName;
- }
- public void setLastName(String lastName){
- this.lastName = lastName;
- }
- public void setMiddleInitial(char middleInitial){
- this.middleInitial = middleInitial;
- }
- 28.
- encapsulates makes it so the class is easy to use and values are not set to what they are not intended to be set at.
- 29.
- cohesion allows the class to represent a single clear abstraction.
- 30.
- Not including i/o allows the class to have more cohesion.
- 31.
- public String getSymbol(){
- return symbol;
- }
- public int getTotalShares(){
- return totalShares;
- }
- public double getTotalCost(){
- return getTotalCost;
- }
Advertisement
Add Comment
Please, Sign In to add comment