Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // JJX1 - defines class states & behaviors - this is the first class
- public class JJX1 {
- // Each JJX1 has a xsize and ysize
- private int xsize = 5;
- private int ysize = 12;
- // JJX1 constructor - this is an empty constructor as a JJX1 object has pre-set xsize and ysize values
- public JJX1 () {
- }
- // getters and setters
- public int getXsize() {
- return xsize;
- }
- public void setXsize(int xsize) {
- this.xsize = xsize;
- }
- public int getYsize() {
- return ysize;
- }
- public void setYsize(int ysize) {
- this.ysize = ysize;
- }
- }
- ----------------------------------------------------
- //JJX2 - defines class states & behaviors
- public class JJX2 {
- // Main Method
- public static void main(String[] args) {
- // instantiate an instance of JJX1
- JJX1 JJX1sum = new JJX1();
- // now make your sum by getting the values from your instance of JJX1
- int z = JJX1sum.getXsize() + JJX1sum.getYsize();
- // printout to console to test
- System.out.println(z);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement