Skip to content

Instantly share code, notes, and snippets.

@jmurth1234
Created February 23, 2017 14:30
Show Gist options
  • Save jmurth1234/260cbcf87935e20e306e62dc11ce9e15 to your computer and use it in GitHub Desktop.
Save jmurth1234/260cbcf87935e20e306e62dc11ce9e15 to your computer and use it in GitHub Desktop.
my session created by rymate1234 - https://repl.it/FvL2/3
class Main {
public static void main(String[] args) {
System.out.println("hello world");
Triangle lab = new Triangle("simple", 3, 4);
System.out.println(lab);
lab.printStyle();
}
}
public class Triangle extends TwoDShapeForLab {
private String style;
public Triangle(String style, double width, double length) {
super(width, length);
this.style = style;
}
public double area()
{
return (getWidth() * getLength()) / 2;
}
public String getStyle()
{
return style;
}
public void printStyle()
{
System.out.println(getStyle());
}
}
/**
* Write a description of class TwoDShapeForLab here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class TwoDShapeForLab
{
private double width;
private double length;
/**
* Parameterized constructor for TwoDShapeForLab
*
* @param width the shape's width
* @param length the shape's length
*/
public TwoDShapeForLab(double width, double length)
{
this.width = width;
this.length = length;
}
/**
* Get the shape's width
*
* @return the width
*/
public double getWidth()
{
return width;
}
/**
* Get the shape's length
*
* @return the length
*/
public double getLength()
{
return length;
}
public String toString()
{
return "Width and length are " + width + " and " + length;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment