ArrayList time
This commit is contained in:
14
Semester 2/Assignments/lab4_CalebFontenot/pom.xml
Normal file
14
Semester 2/Assignments/lab4_CalebFontenot/pom.xml
Normal file
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.calebfontenot</groupId>
|
||||
<artifactId>lab4_CalebFontenot</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
<exec.mainClass>com.calebfontenot.lab4_calebfontenot.Lab4_CalebFontenot</exec.mainClass>
|
||||
</properties>
|
||||
</project>
|
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||
*/
|
||||
package com.calebfontenot.lab4_calebfontenot;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
*/
|
||||
public class Circle extends GeometricObject {
|
||||
private double radius;
|
||||
|
||||
public Circle() {
|
||||
}
|
||||
|
||||
public Circle(double radius) {
|
||||
this.radius = radius;
|
||||
}
|
||||
|
||||
/** Return radius */
|
||||
public double getRadius() {
|
||||
return radius;
|
||||
}
|
||||
|
||||
/** Set a new radius */
|
||||
public void setRadius(double radius) {
|
||||
this.radius = radius;
|
||||
}
|
||||
|
||||
@Override /** Return area */
|
||||
public double getArea() {
|
||||
return radius * radius * Math.PI;
|
||||
}
|
||||
|
||||
/** Return diameter */
|
||||
public double getDiameter() {
|
||||
return 2 * radius;
|
||||
}
|
||||
|
||||
@Override /** Return perimeter */
|
||||
public double getPerimeter() {
|
||||
return 2 * radius * Math.PI;
|
||||
}
|
||||
|
||||
/* Print the circle info */
|
||||
public void printCircle() {
|
||||
System.out.println("The circle is created " + getDateCreated() +
|
||||
" and the radius is " + radius);
|
||||
}
|
||||
}
|
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||
*/
|
||||
package com.calebfontenot.lab4_calebfontenot;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
*/
|
||||
public abstract class GeometricObject {
|
||||
private String color = "white";
|
||||
private boolean filled;
|
||||
private java.util.Date dateCreated;
|
||||
|
||||
/** Construct a default geometric object */
|
||||
protected GeometricObject() {
|
||||
dateCreated = new java.util.Date();
|
||||
}
|
||||
|
||||
/** Construct a geometric object with color and filled value */
|
||||
protected GeometricObject(String color, boolean filled) {
|
||||
dateCreated = new java.util.Date();
|
||||
this.color = color;
|
||||
this.filled = filled;
|
||||
}
|
||||
|
||||
/** Return color */
|
||||
public String getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
/** Set a new color */
|
||||
public void setColor(String color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
/** Return filled. Since filled is boolean,
|
||||
* the get method is named isFilled */
|
||||
public boolean isFilled() {
|
||||
return filled;
|
||||
}
|
||||
|
||||
/** Set a new filled */
|
||||
public void setFilled(boolean filled) {
|
||||
this.filled = filled;
|
||||
}
|
||||
|
||||
/** Get dateCreated */
|
||||
public java.util.Date getDateCreated() {
|
||||
return dateCreated;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "GeometricObject{" + "color=" + color + ", filled=" + filled + ", dateCreated=" + dateCreated + '}';
|
||||
}
|
||||
|
||||
/** Abstract method getArea */
|
||||
public abstract double getArea();
|
||||
|
||||
/** Abstract method getPerimeter */
|
||||
public abstract double getPerimeter();
|
||||
}
|
@@ -0,0 +1,16 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
*/
|
||||
|
||||
package com.calebfontenot.lab4_calebfontenot;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
*/
|
||||
public class Lab4_CalebFontenot {
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println("Hello World!");
|
||||
}
|
||||
}
|
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||
*/
|
||||
package com.calebfontenot.lab4_calebfontenot;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
*/
|
||||
public class Rectangle extends GeometricObject {
|
||||
private double width;
|
||||
private double height;
|
||||
|
||||
public Rectangle() {
|
||||
}
|
||||
|
||||
public Rectangle(double width, double height) {
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
/** Return width */
|
||||
public double getWidth() {
|
||||
return width;
|
||||
}
|
||||
|
||||
/** Set a new width */
|
||||
public void setWidth(double width) {
|
||||
this.width = width;
|
||||
}
|
||||
|
||||
/** Return height */
|
||||
public double getHeight() {
|
||||
return height;
|
||||
}
|
||||
|
||||
/** Set a new height */
|
||||
public void setHeight(double height) {
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
@Override /** Return area */
|
||||
public double getArea() {
|
||||
return width * height;
|
||||
}
|
||||
|
||||
@Override /** Return perimeter */
|
||||
public double getPerimeter() {
|
||||
return 2 * (width + height);
|
||||
}
|
||||
}
|
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||
*/
|
||||
package com.calebfontenot.lab4_calebfontenot;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
*/
|
||||
public class TestCircleRectangle {
|
||||
public static void main(String[] args) {
|
||||
Circle circle = new Circle(1);
|
||||
System.out.println(circle);
|
||||
/*
|
||||
CircleFromSimpleGeometricObject circle =
|
||||
new CircleFromSimpleGeometricObject(1);
|
||||
System.out.println("A circle " + circle.toString());
|
||||
System.out.println("The color is " + circle.getColor());
|
||||
System.out.println("The radius is " + circle.getRadius());
|
||||
System.out.println("The area is " + circle.getArea());
|
||||
System.out.println("The diameter is " + circle.getDiameter());
|
||||
|
||||
RectangleFromSimpleGeometricObject rectangle =
|
||||
new RectangleFromSimpleGeometricObject(2, 4);
|
||||
System.out.println("\nA rectangle " + rectangle.toString());
|
||||
System.out.println("The area is " + rectangle.getArea());
|
||||
System.out.println("The perimeter is " +
|
||||
rectangle.getPerimeter());
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
|
||||
class Apple extends Fruit {
|
||||
|
||||
}
|
||||
|
||||
class Fruit {
|
||||
public Fruit () {}
|
||||
public Fruit(String name) {
|
||||
System.out.println("Fruit's constructior is invoked.");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user