Let's get started with a program that uses variables and methods!
Open Eclipse
Right-Click on your edu.buffalostate.cis425.fa10.exercises..your-username
Choose: File -> New -> class
In the Name:
textbox type: Triangle
Click: Finish
Copy the Triangle.java
Template (Java) code (below)
Paste that code into your new Triangle class in the editor
Change both occurrences of put-your-username-here
Replace the blank on the
private int
line with:
S1, S2, S3
After the
public Triangle ( int s1, int s2, int s3 ) {
comment line add:
S1=s1;
S2=s2;
S3=s3;
Replace the blank after the
public int calculatePerimeter( ) {
line with:
return (S1+S2+S3)
Replace the blank on the
Triangle t = new
line with:
Triangle(10,5,2)
Click the Run icon
Triangle.java
Template (Java)
Triangle
Class Output