woo boy, crazy day today
This commit is contained in:
parent
b189fdc792
commit
d130aa4525
3
.gitignore
vendored
3
.gitignore
vendored
@ -109,3 +109,6 @@
|
||||
/Semester 2/Assignments/lab4_CalebFontenot/target/
|
||||
/Semester 2/Exams/PracticeExam1/target/
|
||||
/Semester 2/Assignments/lab5_CalebFontenot/target/
|
||||
/Semester 1/Assignments/test/target/
|
||||
/Semester 2/Assignments/test/target/
|
||||
/Semester 2/Assignments/lab5__CalebFontenot/target/
|
||||
|
14
Semester 2/Assignments/MP4_CalebFontenot/pom.xml
Normal file
14
Semester 2/Assignments/MP4_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>MP4_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.mp4_calebfontenot.MP4_CalebFontenot</exec.mainClass>
|
||||
</properties>
|
||||
</project>
|
@ -0,0 +1,94 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
*/
|
||||
|
||||
package com.calebfontenot.mp4_calebfontenot;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
*/
|
||||
public abstract class Bicycle {
|
||||
|
||||
private int cadence;
|
||||
private int gear;
|
||||
private int speed;
|
||||
|
||||
public Bicycle(int cadence, int gear, int speed)
|
||||
{
|
||||
this.cadence = cadence;
|
||||
this.gear = gear;
|
||||
this.speed = speed;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the value of speed
|
||||
*
|
||||
* @return the value of speed
|
||||
*/
|
||||
public int getSpeed()
|
||||
{
|
||||
return speed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of speed
|
||||
*
|
||||
* @param speed new value of speed
|
||||
*/
|
||||
public void setSpeed(int speed)
|
||||
{
|
||||
this.speed = speed;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the value of gear
|
||||
*
|
||||
* @return the value of gear
|
||||
*/
|
||||
public int getGear()
|
||||
{
|
||||
return gear;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of gear
|
||||
*
|
||||
* @param gear new value of gear
|
||||
*/
|
||||
public void setGear(int gear)
|
||||
{
|
||||
this.gear = gear;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the value of cadence
|
||||
*
|
||||
* @return the value of cadence
|
||||
*/
|
||||
public int getCadence()
|
||||
{
|
||||
return cadence;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of cadence
|
||||
*
|
||||
* @param cadence new value of cadence
|
||||
*/
|
||||
public void setCadence(int cadence)
|
||||
{
|
||||
this.cadence = cadence;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "Bicycle{" + "cadence=" + cadence + ", gear=" + gear + ", speed=" + speed + '}';
|
||||
}
|
||||
|
||||
abstract Details calculatedDetains();
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 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.mp4_calebfontenot;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
*/
|
||||
public class Details {
|
||||
|
||||
private int rank;
|
||||
private String info;
|
||||
|
||||
public void setRank(int rank)
|
||||
{
|
||||
this.rank = rank;
|
||||
}
|
||||
|
||||
public int getRank()
|
||||
{
|
||||
return rank;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static Details getDetails(Bicycle b) {
|
||||
if (b instanceof SpeedBike) {
|
||||
if ((SpeedBike) b.speed) {
|
||||
|
||||
}
|
||||
} else if (b instanceof MountainBike) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 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.mp4_calebfontenot;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
*/
|
||||
public class MountainBike extends Bicycle {
|
||||
|
||||
private int seatHeight;
|
||||
|
||||
public MountainBike( int seatHeight, int cadence, int gear, int speed)
|
||||
{
|
||||
super(cadence, gear, speed);
|
||||
this.seatHeight = seatHeight;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return super.toString() + "MountainBike{" + "seatHeight=" + seatHeight + '}';
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of seatHeight
|
||||
*
|
||||
* @param seatHeight new value of seatHeight
|
||||
*/
|
||||
public void setSeatHeight(int seatHeight)
|
||||
{
|
||||
this.seatHeight = seatHeight;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* 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.mp4_calebfontenot;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
*/
|
||||
public class SpeedBike extends Bicycle{
|
||||
|
||||
private double weight;
|
||||
|
||||
public SpeedBike(double weight, int cadence, int gear, int speed)
|
||||
{
|
||||
super(cadence, gear, speed);
|
||||
this.weight = weight;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value of weight
|
||||
*
|
||||
* @return the value of weight
|
||||
*/
|
||||
public double getWeight()
|
||||
{
|
||||
return weight;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of weight
|
||||
*
|
||||
* @param weight new value of weight
|
||||
*/
|
||||
public void setWeight(double weight)
|
||||
{
|
||||
this.weight = weight;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return super.toString() + "SpeedBike{" + "weight=" + weight + '}';
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,139 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Company.java</title>
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||
<style type="text/css">
|
||||
<!--
|
||||
body {color: #a9b7c6; background-color: #2b2b2b; font-family: monospace}
|
||||
pre {color: #a9b7c6; background-color: #2b2b2b; font-family: monospace}
|
||||
table {color: #888888; background-color: #313335; font-family: monospace}
|
||||
.comment {color: #808080}
|
||||
.whitespace {color: #505050}
|
||||
.ST0 {color: #808080; font-family: monospace; font-weight: bold}
|
||||
.literal {color: #cc7832}
|
||||
-->
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<table width="100%"><tr><td align="center">/home/caleb/ASDV-Java/Semester 2/Assignments/lab5_CalebFontenot/src/main/java/com/calebfontenot/test/Company.java</td></tr></table>
|
||||
<pre>
|
||||
<span class="comment">/*</span>
|
||||
<span class="comment"> * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license</span>
|
||||
<span class="comment"> * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template</span>
|
||||
<span class="comment"> */</span>
|
||||
<span class="literal">package</span> com.calebfontenot.test;
|
||||
|
||||
<span class="literal">import</span> java.util.ArrayList;
|
||||
<span class="literal">import</span> java.util.Date;
|
||||
<span class="literal">import</span> java.util.GregorianCalendar;
|
||||
|
||||
<span class="comment">/**</span>
|
||||
<span class="comment"> *</span>
|
||||
<span class="comment"> * </span><span class="ST0">@author</span> <span class="comment">caleb</span>
|
||||
<span class="comment">*/</span>
|
||||
public class Company {
|
||||
|
||||
private ArrayList<Employee> employees = new ArrayList<Employee>();
|
||||
|
||||
public boolean addToGroup(Employee e) {
|
||||
employees.add(e);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean removeFromGroup(Employee e) {
|
||||
if (employees.contains(e)) {
|
||||
employees.remove(e);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static void sortBySalary (ArrayList<Employee> arr) {
|
||||
for (int i = 0; i < arr.size() - 1; ++i) {
|
||||
for (int j = i+1; j < arr.size(); ++j)
|
||||
if (arr.get(i).computePay() < arr.get(j).computePay()) {
|
||||
Employee temp = arr.get(i);
|
||||
arr.set(i, arr.get(j)) ;
|
||||
arr.set(j, temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void sortBySalary (Employee arr[]) {
|
||||
for (int i = 0; i < arr.length - 1; ++i) {
|
||||
for (int j = i+1; j < arr.length; ++j)
|
||||
if (arr[i].computePay() < arr[j].computePay()) {
|
||||
Employee temp = arr[i];
|
||||
arr[i] = arr[j];
|
||||
arr[j] = temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "Company{" + "employees=" + employees + '}';
|
||||
}
|
||||
|
||||
public static void print(Employee[] arr) {
|
||||
for(Employee e: arr) {
|
||||
System.out.println(e);
|
||||
System.out.println("-----------------------");
|
||||
}
|
||||
}
|
||||
|
||||
public static void print(Object[] arr) {
|
||||
for (Object e: arr) {
|
||||
if (e instanceof Employee)
|
||||
System.out.println(e + " " + ((Employee) e).computePay());
|
||||
System.out.println("-----------------------");
|
||||
}
|
||||
}
|
||||
/*
|
||||
public static void main(String[] args) {
|
||||
SalaryEmployee se1 = new SalaryEmployee(50000, "john", new Date());
|
||||
SalaryEmployee se2 = new SalaryEmployee(60000, "mary", new Date());
|
||||
WageEmployee we1 = new WageEmployee(20, 150, "paul", new Date());
|
||||
WageEmployee we2 = new WageEmployee(20, 150, "anna", new Date());
|
||||
|
||||
ArrayList<Employee> list = new ArrayList<>();
|
||||
list.add(se1);
|
||||
list.add(se2);
|
||||
list.add(we1);
|
||||
list.add(we2);
|
||||
System.out.println(list);
|
||||
|
||||
Employee[] ar = new Employee[4];
|
||||
ar[0] = se1;
|
||||
ar[1] = se2;
|
||||
ar[2] = we1;
|
||||
ar[3] = we2;
|
||||
|
||||
print(ar);
|
||||
sortBySalary(ar);
|
||||
print(ar);
|
||||
}
|
||||
*/
|
||||
public static void main(String[] args)
|
||||
{
|
||||
Company c =new Company();
|
||||
c.addToGroup(new WageEmployee(10, 160, "Mary Poppins", new GregorianCalendar(1990, 12, 18).getTime()));
|
||||
c.addToGroup(new WageEmployee(12, 160, "John Wayne", new GregorianCalendar(1920, 11, 2).getTime()));
|
||||
c.addToGroup(new SalaryEmployee(70000, "Marylyn Monroe", new GregorianCalendar(1920, 11, 2).getTime()));
|
||||
c.addToGroup(new Manager(40000, "Brad Pitt", new GregorianCalendar(1920, 11, 2).getTime()));
|
||||
System.out.println(c);
|
||||
System.out.println("------------------------------------");
|
||||
Company.print(c.employees.toArray());
|
||||
System.out.println("------------------------------------");
|
||||
System.out.println("sort by salary");
|
||||
Company.sortBySalary(c.employees);
|
||||
Company.print(c.employees.toArray());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
</pre></body>
|
||||
</html>
|
@ -0,0 +1,60 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Employee.java</title>
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||
<style type="text/css">
|
||||
<!--
|
||||
body {color: #a9b7c6; background-color: #2b2b2b; font-family: monospace}
|
||||
pre {color: #a9b7c6; background-color: #2b2b2b; font-family: monospace}
|
||||
table {color: #888888; background-color: #313335; font-family: monospace}
|
||||
.string {color: #6a8759}
|
||||
.comment {color: #808080}
|
||||
.whitespace {color: #505050}
|
||||
.ST0 {color: #808080; font-family: monospace; font-weight: bold}
|
||||
.literal {color: #cc7832}
|
||||
-->
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<table width="100%"><tr><td align="center">/home/caleb/ASDV-Java/Semester 2/Assignments/lab5_CalebFontenot/src/main/java/com/calebfontenot/test/Employee.java</td></tr></table>
|
||||
<pre>
|
||||
<span class="comment">/*</span>
|
||||
<span class="comment"> * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license</span>
|
||||
<span class="comment"> * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template</span>
|
||||
<span class="comment"> */</span>
|
||||
<span class="literal">package</span> com.calebfontenot.test;
|
||||
|
||||
<span class="literal">import</span> java.util.Date;
|
||||
|
||||
<span class="comment">/**</span>
|
||||
<span class="comment"> *</span>
|
||||
<span class="comment"> * </span><span class="ST0">@author</span> <span class="comment">Jude</span>
|
||||
<span class="comment">*/</span>
|
||||
<span class="literal">public</span> <span class="literal">abstract</span> <span class="literal">class</span> Employee {
|
||||
<span class="literal">private</span> String name;
|
||||
<span class="literal">private</span> Date dateHired;
|
||||
|
||||
<span class="literal">public</span> Employee() { }
|
||||
|
||||
<span class="literal">public</span> Employee(String name, Date dateHired) {
|
||||
<span class="literal">this</span>.name = name;
|
||||
<span class="literal">this</span>.dateHired = dateHired;
|
||||
}
|
||||
|
||||
<span class="literal">public</span> String getName() { <span class="literal">return</span> name; }
|
||||
<span class="literal">public</span> <span class="literal">void</span> setName(String newName) { name = newName; }
|
||||
|
||||
<span class="literal">public</span> Date getDateHired() { <span class="literal">return</span> dateHired; }
|
||||
<span class="literal">public</span> <span class="literal">void</span> setDateHired(Date date) { dateHired = date; }
|
||||
|
||||
@Override
|
||||
<span class="literal">public</span> String toString() {
|
||||
<span class="literal">return</span> <span class="string">"</span><span class="string">Employee{</span><span class="string">"</span> + <span class="string">"</span><span class="string">name=</span><span class="string">"</span> + name + <span class="string">"</span><span class="string">, dateHired=</span><span class="string">"</span> + dateHired + <span class="string">'</span><span class="string">}</span><span class="string">'</span>;
|
||||
}
|
||||
|
||||
<span class="literal">public</span> <span class="literal">abstract</span> <span class="literal">double</span> computePay();
|
||||
}
|
||||
|
||||
</pre></body>
|
||||
</html>
|
@ -0,0 +1,57 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Manager.java</title>
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||
<style type="text/css">
|
||||
<!--
|
||||
body {color: #a9b7c6; background-color: #2b2b2b; font-family: monospace}
|
||||
pre {color: #a9b7c6; background-color: #2b2b2b; font-family: monospace}
|
||||
table {color: #888888; background-color: #313335; font-family: monospace}
|
||||
.number {color: #6897bb}
|
||||
.string {color: #6a8759}
|
||||
.comment {color: #808080}
|
||||
.whitespace {color: #505050}
|
||||
.ST0 {color: #808080; font-family: monospace; font-weight: bold}
|
||||
.literal {color: #cc7832}
|
||||
-->
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<table width="100%"><tr><td align="center">/home/caleb/ASDV-Java/Semester 2/Assignments/lab5_CalebFontenot/src/main/java/com/calebfontenot/test/Manager.java</td></tr></table>
|
||||
<pre>
|
||||
<span class="comment">/*</span>
|
||||
<span class="comment"> * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license</span>
|
||||
<span class="comment"> * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template</span>
|
||||
<span class="comment"> */</span>
|
||||
<span class="literal">package</span> com.calebfontenot.test;
|
||||
|
||||
<span class="literal">import</span> java.util.ArrayList;
|
||||
<span class="literal">import</span> java.util.Date;
|
||||
|
||||
<span class="comment">/**</span>
|
||||
<span class="comment"> *</span>
|
||||
<span class="comment"> * </span><span class="ST0">@author</span> <span class="comment">caleb</span>
|
||||
<span class="comment">*/</span>
|
||||
<span class="literal">public</span> <span class="literal">class</span> Manager <span class="literal">extends</span> SalaryEmployee {
|
||||
|
||||
|
||||
<span class="literal">public</span> Manager(<span class="literal">double</span> yearlySalary, String name, Date dateHired) {
|
||||
<span class="literal">super</span>(yearlySalary, name, dateHired);
|
||||
}
|
||||
|
||||
@Override
|
||||
<span class="literal">public</span> <span class="literal">double</span> computePay() {
|
||||
<span class="literal">return</span> <span class="literal">super</span>.computePay() * <span class="number">2</span>;
|
||||
}
|
||||
|
||||
@Override
|
||||
<span class="literal">public</span> String toString()
|
||||
{
|
||||
<span class="literal">return</span> <span class="literal">super</span>.toString() + <span class="string">"</span><span class="string">Manager{</span><span class="string">"</span> + <span class="string">'</span><span class="string">}</span><span class="string">'</span>;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
</pre></body>
|
||||
</html>
|
@ -0,0 +1,60 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>SalaryEmployee.java</title>
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||
<style type="text/css">
|
||||
<!--
|
||||
body {color: #a9b7c6; background-color: #2b2b2b; font-family: monospace}
|
||||
pre {color: #a9b7c6; background-color: #2b2b2b; font-family: monospace}
|
||||
table {color: #888888; background-color: #313335; font-family: monospace}
|
||||
.number {color: #6897bb}
|
||||
.string {color: #6a8759}
|
||||
.comment {color: #808080}
|
||||
.whitespace {color: #505050}
|
||||
.ST0 {color: #808080; font-family: monospace; font-weight: bold}
|
||||
.literal {color: #cc7832}
|
||||
-->
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<table width="100%"><tr><td align="center">/home/caleb/ASDV-Java/Semester 2/Assignments/lab5_CalebFontenot/src/main/java/com/calebfontenot/test/SalaryEmployee.java</td></tr></table>
|
||||
<pre>
|
||||
<span class="comment">/*</span>
|
||||
<span class="comment"> * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license</span>
|
||||
<span class="comment"> * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template</span>
|
||||
<span class="comment"> */</span>
|
||||
<span class="literal">package</span> com.calebfontenot.test;
|
||||
|
||||
<span class="literal">import</span> java.util.Date;
|
||||
|
||||
<span class="comment">/**</span>
|
||||
<span class="comment"> *</span>
|
||||
<span class="comment"> * </span><span class="ST0">@author</span> <span class="comment">Jude</span>
|
||||
<span class="comment">*/</span>
|
||||
<span class="literal">public</span> <span class="literal">class</span> SalaryEmployee <span class="literal">extends</span> Employee {
|
||||
|
||||
<span class="literal">private</span> <span class="literal">double</span> yearlySalary;
|
||||
<span class="literal">public</span> <span class="literal">double</span> getYearlySalary() { <span class="literal">return</span> yearlySalary; }
|
||||
<span class="literal">public</span> <span class="literal">void</span> setYearlySalary(<span class="literal">double</span> yearlySalary) { <span class="literal">this</span>.yearlySalary = yearlySalary; }
|
||||
|
||||
<span class="literal">public</span> SalaryEmployee(<span class="literal">double</span> yearlySalary, String name, Date dateHired) {
|
||||
<span class="literal">super</span>(name, dateHired);
|
||||
<span class="literal">this</span>.yearlySalary = yearlySalary;
|
||||
}
|
||||
|
||||
@Override
|
||||
<span class="literal">public</span> <span class="literal">double</span> computePay() {
|
||||
<span class="literal">return</span> <span class="literal">this</span>.yearlySalary / <span class="number">52</span>;
|
||||
}
|
||||
|
||||
@Override
|
||||
<span class="literal">public</span> String toString() {
|
||||
<span class="literal">return</span> <span class="literal">super</span>.toString() + <span class="string">"</span><span class="string">SalaryEmployee{</span><span class="string">"</span> + <span class="string">"</span><span class="string">yearlySalary=</span><span class="string">"</span> + yearlySalary + <span class="string">'</span><span class="string">}</span><span class="string">'</span>;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
</pre></body>
|
||||
</html>
|
@ -0,0 +1,73 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>WageEmployee.java</title>
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||
<style type="text/css">
|
||||
<!--
|
||||
body {color: #a9b7c6; background-color: #2b2b2b; font-family: monospace}
|
||||
pre {color: #a9b7c6; background-color: #2b2b2b; font-family: monospace}
|
||||
table {color: #888888; background-color: #313335; font-family: monospace}
|
||||
.string {color: #6a8759}
|
||||
.comment {color: #808080}
|
||||
.whitespace {color: #505050}
|
||||
.ST0 {color: #808080; font-family: monospace; font-weight: bold}
|
||||
.literal {color: #cc7832}
|
||||
-->
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<table width="100%"><tr><td align="center">/home/caleb/ASDV-Java/Semester 2/Assignments/lab5_CalebFontenot/src/main/java/com/calebfontenot/test/WageEmployee.java</td></tr></table>
|
||||
<pre>
|
||||
<span class="comment">/*</span>
|
||||
<span class="comment"> * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license</span>
|
||||
<span class="comment"> * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template</span>
|
||||
<span class="comment"> */</span>
|
||||
<span class="literal">package</span> com.calebfontenot.test;
|
||||
|
||||
<span class="literal">import</span> java.util.Date;
|
||||
|
||||
<span class="comment">/**</span>
|
||||
<span class="comment"> *</span>
|
||||
<span class="comment"> * </span><span class="ST0">@author</span> <span class="comment">Jude</span>
|
||||
<span class="comment">*/</span>
|
||||
<span class="literal">public</span> <span class="literal">class</span> WageEmployee <span class="literal">extends</span> Employee {
|
||||
|
||||
<span class="literal">private</span> <span class="literal">double</span> wage;
|
||||
|
||||
|
||||
<span class="literal">public</span> WageEmployee(<span class="literal">double</span> wage, <span class="literal">double</span> hours)
|
||||
{
|
||||
<span class="literal">this</span>.wage = wage;
|
||||
<span class="literal">this</span>.hours = hours;
|
||||
}
|
||||
|
||||
<span class="literal">public</span> WageEmployee(<span class="literal">double</span> wage, <span class="literal">double</span> hours, String name, Date dateHired)
|
||||
{
|
||||
<span class="literal">super</span>(name, dateHired);
|
||||
<span class="literal">this</span>.wage = wage;
|
||||
<span class="literal">this</span>.hours = hours;
|
||||
}
|
||||
|
||||
<span class="literal">public</span> <span class="literal">double</span> getWage() { <span class="literal">return</span> wage; }
|
||||
<span class="literal">public</span> <span class="literal">void</span> setWage(<span class="literal">double</span> wage) { <span class="literal">this</span>.wage = wage; }
|
||||
|
||||
<span class="literal">private</span> <span class="literal">double</span> hours;
|
||||
<span class="literal">public</span> <span class="literal">double</span> getHours() { <span class="literal">return</span> hours; }
|
||||
<span class="literal">public</span> <span class="literal">void</span> setHours(<span class="literal">double</span> hours) { <span class="literal">this</span>.hours = hours; }
|
||||
|
||||
@Override
|
||||
<span class="literal">public</span> <span class="literal">double</span> computePay() {
|
||||
<span class="literal">return</span> <span class="literal">this</span>.wage * <span class="literal">this</span>.hours;
|
||||
}
|
||||
|
||||
@Override
|
||||
<span class="literal">public</span> String toString() {
|
||||
<span class="literal">return</span> <span class="literal">super</span>.toString() + <span class="string">"</span><span class="string">WageEmployee{</span><span class="string">"</span> + <span class="string">"</span><span class="string">wage=</span><span class="string">"</span> + wage + <span class="string">"</span><span class="string">, hours=</span><span class="string">"</span> + hours + <span class="string">'</span><span class="string">}</span><span class="string">'</span>;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
</pre></body>
|
||||
</html>
|
15
Semester 2/Assignments/lab5_CalebFontenot/pom.xml
Normal file
15
Semester 2/Assignments/lab5_CalebFontenot/pom.xml
Normal file
@ -0,0 +1,15 @@
|
||||
<?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>lab5_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.test.Test</exec.mainClass>
|
||||
</properties>
|
||||
<name>lab5_CalebFontenot</name>
|
||||
</project>
|
@ -0,0 +1,116 @@
|
||||
/*
|
||||
* 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.test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
*/
|
||||
public class Company {
|
||||
|
||||
private ArrayList<Employee> employees = new ArrayList<Employee>();
|
||||
|
||||
public boolean addToGroup(Employee e) {
|
||||
employees.add(e);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean removeFromGroup(Employee e) {
|
||||
if (employees.contains(e)) {
|
||||
employees.remove(e);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static void sortBySalary (ArrayList<Employee> arr) {
|
||||
for (int i = 0; i < arr.size() - 1; ++i) {
|
||||
for (int j = i+1; j < arr.size(); ++j)
|
||||
if (arr.get(i).computePay() < arr.get(j).computePay()) {
|
||||
Employee temp = arr.get(i);
|
||||
arr.set(i, arr.get(j)) ;
|
||||
arr.set(j, temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void sortBySalary (Employee arr[]) {
|
||||
for (int i = 0; i < arr.length - 1; ++i) {
|
||||
for (int j = i+1; j < arr.length; ++j)
|
||||
if (arr[i].computePay() < arr[j].computePay()) {
|
||||
Employee temp = arr[i];
|
||||
arr[i] = arr[j];
|
||||
arr[j] = temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "Company{" + "employees=" + employees + '}';
|
||||
}
|
||||
|
||||
public static void print(Employee[] arr) {
|
||||
for(Employee e: arr) {
|
||||
System.out.println(e);
|
||||
System.out.println("-----------------------");
|
||||
}
|
||||
}
|
||||
|
||||
public static void print(Object[] arr) {
|
||||
for (Object e: arr) {
|
||||
if (e instanceof Employee)
|
||||
System.out.println(e + " " + ((Employee) e).computePay());
|
||||
System.out.println("-----------------------");
|
||||
}
|
||||
}
|
||||
/*
|
||||
public static void main(String[] args) {
|
||||
SalaryEmployee se1 = new SalaryEmployee(50000, "john", new Date());
|
||||
SalaryEmployee se2 = new SalaryEmployee(60000, "mary", new Date());
|
||||
WageEmployee we1 = new WageEmployee(20, 150, "paul", new Date());
|
||||
WageEmployee we2 = new WageEmployee(20, 150, "anna", new Date());
|
||||
|
||||
ArrayList<Employee> list = new ArrayList<>();
|
||||
list.add(se1);
|
||||
list.add(se2);
|
||||
list.add(we1);
|
||||
list.add(we2);
|
||||
System.out.println(list);
|
||||
|
||||
Employee[] ar = new Employee[4];
|
||||
ar[0] = se1;
|
||||
ar[1] = se2;
|
||||
ar[2] = we1;
|
||||
ar[3] = we2;
|
||||
|
||||
print(ar);
|
||||
sortBySalary(ar);
|
||||
print(ar);
|
||||
}
|
||||
*/
|
||||
public static void main(String[] args)
|
||||
{
|
||||
Company c =new Company();
|
||||
c.addToGroup(new WageEmployee(10, 160, "Mary Poppins", new GregorianCalendar(1990, 12, 18).getTime()));
|
||||
c.addToGroup(new WageEmployee(12, 160, "John Wayne", new GregorianCalendar(1920, 11, 2).getTime()));
|
||||
c.addToGroup(new SalaryEmployee(70000, "Marylyn Monroe", new GregorianCalendar(1920, 11, 2).getTime()));
|
||||
c.addToGroup(new Manager(40000, "Brad Pitt", new GregorianCalendar(1920, 11, 2).getTime()));
|
||||
System.out.println(c);
|
||||
System.out.println("------------------------------------");
|
||||
Company.print(c.employees.toArray());
|
||||
System.out.println("------------------------------------");
|
||||
System.out.println("sort by salary");
|
||||
Company.sortBySalary(c.employees);
|
||||
Company.print(c.employees.toArray());
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* 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.test;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jude
|
||||
*/
|
||||
public abstract class Employee {
|
||||
private String name;
|
||||
private Date dateHired;
|
||||
|
||||
public Employee() { }
|
||||
|
||||
public Employee(String name, Date dateHired) {
|
||||
this.name = name;
|
||||
this.dateHired = dateHired;
|
||||
}
|
||||
|
||||
public String getName() { return name; }
|
||||
public void setName(String newName) { name = newName; }
|
||||
|
||||
public Date getDateHired() { return dateHired; }
|
||||
public void setDateHired(Date date) { dateHired = date; }
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Employee{" + "name=" + name + ", dateHired=" + dateHired + '}';
|
||||
}
|
||||
|
||||
public abstract double computePay();
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
/*
|
||||
* 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.test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
*/
|
||||
public class Manager extends SalaryEmployee {
|
||||
|
||||
|
||||
public Manager(double yearlySalary, String name, Date dateHired) {
|
||||
super(yearlySalary, name, dateHired);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double computePay() {
|
||||
return super.computePay() * 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return super.toString() + "Manager{" + '}';
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
/*
|
||||
* 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.test;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jude
|
||||
*/
|
||||
public class SalaryEmployee extends Employee {
|
||||
|
||||
private double yearlySalary;
|
||||
public double getYearlySalary() { return yearlySalary; }
|
||||
public void setYearlySalary(double yearlySalary) { this.yearlySalary = yearlySalary; }
|
||||
|
||||
public SalaryEmployee(double yearlySalary, String name, Date dateHired) {
|
||||
super(name, dateHired);
|
||||
this.yearlySalary = yearlySalary;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double computePay() {
|
||||
return this.yearlySalary / 52;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return super.toString() + "SalaryEmployee{" + "yearlySalary=" + yearlySalary + '}';
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* 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.test;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jude
|
||||
*/
|
||||
public class WageEmployee extends Employee {
|
||||
|
||||
private double wage;
|
||||
|
||||
|
||||
public WageEmployee(double wage, double hours)
|
||||
{
|
||||
this.wage = wage;
|
||||
this.hours = hours;
|
||||
}
|
||||
|
||||
public WageEmployee(double wage, double hours, String name, Date dateHired)
|
||||
{
|
||||
super(name, dateHired);
|
||||
this.wage = wage;
|
||||
this.hours = hours;
|
||||
}
|
||||
|
||||
public double getWage() { return wage; }
|
||||
public void setWage(double wage) { this.wage = wage; }
|
||||
|
||||
private double hours;
|
||||
public double getHours() { return hours; }
|
||||
public void setHours(double hours) { this.hours = hours; }
|
||||
|
||||
@Override
|
||||
public double computePay() {
|
||||
return this.wage * this.hours;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return super.toString() + "WageEmployee{" + "wage=" + wage + ", hours=" + hours + '}';
|
||||
}
|
||||
|
||||
|
||||
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,5 @@
|
||||
#Generated by Maven
|
||||
#Thu Mar 02 10:45:46 CST 2023
|
||||
version=1.0-SNAPSHOT
|
||||
groupId=com.calebfontenot
|
||||
artifactId=lab5_CalebFontenot
|
@ -0,0 +1,3 @@
|
||||
com/calebfontenot/lab5_calebfontenot/A.class
|
||||
com/calebfontenot/lab5_calebfontenot/B.class
|
||||
com/calebfontenot/lab5_calebfontenot/lab5_CalebFontenot.class
|
@ -0,0 +1,2 @@
|
||||
/home/caleb/ASDV-Java/Semester 2/Assignments/lab5_CalebFontenot/src/main/java/com/calebfontenot/lab5_calebfontenot/A.java
|
||||
/home/caleb/ASDV-Java/Semester 2/Assignments/lab5_CalebFontenot/src/main/java/com/calebfontenot/lab5_calebfontenot/lab5_CalebFontenot.java
|
BIN
Semester 2/ZIPs/lab5_CalebFontenot.zip
Normal file
BIN
Semester 2/ZIPs/lab5_CalebFontenot.zip
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user