1 / 16

public class Square { <instance variables> <constructors> <methods> }

public class Square { <instance variables> <constructors> <methods> }. public class Square { double xCoord ; double yCoord ; Color color ; double length; …. }. public class Square { … public Square ( double x, double y, double len , double c) { xCoord = x;

dixie
Download Presentation

public class Square { <instance variables> <constructors> <methods> }

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. publicclass Square { <instance variables> <constructors> <methods> }

  2. public class Square { doublexCoord; doubleyCoord; Colorcolor; double length; …. }

  3. public class Square { … publicSquare(double x, double y, doublelen, double c) { xCoord = x; yCoord = y; length = len; color = c; } … }

  4. public class Square { … publicvoiddraw() { … } publicvoiderase() { … } publicvoidmove(doubledx, doubledy) { … } }

  5. implementation hiding sq Square(x,y,len,color) draw() erase() move(dx, dy) API

  6. private variables No one but you can touch your private parts

  7. public class Square { privatedoublexCoord; privatedoubleyCoord; privateColor color; privatedouble length; …. }

  8. getters getColor() getX() getY() getLength()

  9. public class Square { … publicdoublegetX() { returnxCoord; } publicdoublegetY() { returnyCoord; } publicColorgetColor() { return color; } publicdoublegetLength() { returnlen; } }

  10. setters setColor() setPos() setLength()

  11. public class Square { … publicdoublesetPos(doublex, doubley) { xCoord = x; yCoord = y; } publicdoublesetColor(Colorc) { … } publicdoublesetLength(doublelen) { … } }

  12. publicclass Circle { <instance variables> <constructors> <methods> }

More Related