Created
November 10, 2021 19:50
-
-
Save tamirazrab/57cd3f27a53f3d1fb5b03983d289df9f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Rectangle | |
| { | |
| int left, right, up, down; | |
| } | |
| public class Main | |
| { | |
| public static void main (String[]args) | |
| { | |
| Rectangle r1 = new Rectangle (); | |
| r1.left = 2; | |
| r1.right = 3; | |
| r1.up = 5; | |
| r1.down = 6; | |
| int sum = r1.left + r1.right + r1.up + r1.down; | |
| System.out.printf ("Sum of all sides of r1 : %d\n", sum); | |
| Rectangle r2 = new Rectangle (); | |
| r2.left = 2; | |
| r2.right = 3; | |
| r2.up = 5; | |
| r2.down = 6; | |
| sum = r2.left + r2.right + r2.up + r2.down; | |
| System.out.printf ("Sum of all sides of r2 : %d\n", sum); | |
| Rectangle r3 = new Rectangle (); | |
| r3.left = 2; | |
| r3.right = 3; | |
| r3.up = 5; | |
| r3.down = 6; | |
| sum = r3.left + r3.right + r3.up + r3.down; | |
| System.out.printf ("Sum of all sides of r3 : %d\n", sum); | |
| Rectangle r4 = new Rectangle (); | |
| r4.left = 2; | |
| r4.right = 3; | |
| r4.up = 5; | |
| r4.down = 6; | |
| sum = r4.left + r4.right + r4.up + r4.down; | |
| System.out.printf ("Sum of all sides of r4 : %d", sum); | |
| } | |
| } | |
| class Car | |
| { | |
| String model, color; | |
| } | |
| public class Main | |
| { | |
| public static void main (String[]args) | |
| { | |
| Car c1 = new Car (); | |
| c1.model = "Merces"; | |
| c1.color = "Lime Light"; | |
| System.out.printf ("Car 1 Model : %s, Color: %s\n", c1.model, c1.color); | |
| Car c2 = new Car (); | |
| c2.model = "Doge"; | |
| c2.color = "Dark Red"; | |
| System.out.printf ("Car 2 Model : %s, Color: %s", c2.model, c2.color); | |
| } | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment