Reset author name to chosen name ✨
This commit is contained in:
@@ -1,16 +0,0 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
*/
|
||||
|
||||
package com.chloefontenot.lab8_2_chloefontenot;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author chloe
|
||||
*/
|
||||
public class Lab8_2_ChloeFontenot {
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println("Hello World!");
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
/*
|
||||
* 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.chloefontenot.lab8_2_chloefontenot;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author chloe
|
||||
*/
|
||||
public class NumberX implements Comparable<NumberX> {
|
||||
int x;
|
||||
public NumberX(int x) {
|
||||
this.x = x;
|
||||
}
|
||||
@Override
|
||||
public int compareTo(NumberX o)
|
||||
{
|
||||
if (this.x == o.x) {
|
||||
return 0;
|
||||
} else if (this.x > o.x) {
|
||||
return 1;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
public static void main(String[] args)
|
||||
{
|
||||
NumberX x1 = new NumberX(10);
|
||||
NumberX x2 = new NumberX(20);
|
||||
NumberX x3 = new NumberX(30);
|
||||
System.out.println(x1.compareTo(x2));
|
||||
System.out.println(x1.compareTo(x3));
|
||||
System.out.println(x2.compareTo(x1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "NumberX{" + "x=" + x + '}';
|
||||
}
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
/*
|
||||
* 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.chloefontenot.lab8_2_chloefontenot;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author chloe
|
||||
*/
|
||||
import java.math.*;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class SortComparableObjects {
|
||||
public static void main(String[] args) {
|
||||
NumberX[] numbers = {new NumberX(20), new NumberX(1), new NumberX(3)};
|
||||
Arrays.sort(numbers);
|
||||
for (NumberX number: numbers) {
|
||||
System.out.println(number);
|
||||
}
|
||||
String[] cities = {"Savannah", "Boston", "Atlanta", "Tampa"};
|
||||
java.util.Arrays.sort(cities);
|
||||
for (String city: cities)
|
||||
System.out.print(city + " ");
|
||||
System.out.println();
|
||||
|
||||
BigInteger[] hugeNumbers = {new BigInteger("2323231092923992"),
|
||||
new BigInteger("432232323239292"),
|
||||
new BigInteger("54623239292")};
|
||||
java.util.Arrays.sort(hugeNumbers);
|
||||
for (BigInteger number: hugeNumbers)
|
||||
System.out.print(number + " ");
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Interface.java to edit this template
|
||||
*/
|
||||
package com.chloefontenot.lab8_2_chloefontenot.interfacesGrouped;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author chloe
|
||||
*/
|
||||
public interface Interface1 {
|
||||
abstract void I1();
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Interface.java to edit this template
|
||||
*/
|
||||
package com.chloefontenot.lab8_2_chloefontenot.interfacesGrouped;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author chloe
|
||||
*/
|
||||
public interface Interface2 {
|
||||
abstract void I2();
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Interface.java to edit this template
|
||||
*/
|
||||
package com.chloefontenot.lab8_2_chloefontenot.interfacesGrouped;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author chloe
|
||||
*/
|
||||
public interface InterfaceGrouped1 extends Interface1, Interface2 {
|
||||
int x = 10; //public static shared by all who implement or extend the interface
|
||||
abstract void IG1();
|
||||
|
||||
static void staticMethodOfInterface() {
|
||||
System.out.println("A static method inside an Interface is shared by every class" +
|
||||
" that implements Interface InterfaceGrouped1.");
|
||||
}
|
||||
default void defaultMethodOfInterface() {
|
||||
System.out.println("The default implementation was used as there was no overriding" +
|
||||
" by a class that was implemented the Interface InterfaceGrouped1.");
|
||||
}
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
/*
|
||||
* 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.chloefontenot.lab8_2_chloefontenot.interfacesGrouped;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author chloe
|
||||
*/
|
||||
public class TestInterfaces implements InterfaceGrouped1 {
|
||||
@Override
|
||||
public void IG1() {
|
||||
System.out.println("TestInterfaces:IG1()");
|
||||
}
|
||||
@Override
|
||||
public void I1() {
|
||||
System.out.println("TestInterfaces:I1()");
|
||||
}
|
||||
@Override
|
||||
public void I2() {
|
||||
System.out.println("testInterfaces:I2()");
|
||||
}
|
||||
@Override
|
||||
public void defaultMethodOfInterface() {
|
||||
System.out.println("overriden implementation of defaultMethodOfInterface");
|
||||
}
|
||||
public static void main(String[] args)
|
||||
{
|
||||
System.out.println(TestInterfaces.x);
|
||||
|
||||
InterfaceGrouped1.staticMethodOfInterface();
|
||||
TestInterfaces ti = new TestInterfaces();
|
||||
ti.I1();
|
||||
ti.I2();
|
||||
ti.IG1();
|
||||
ti.defaultMethodOfInterface();
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Interface.java to edit this template
|
||||
*/
|
||||
package com.chloefontenot.lab8_2_chloefontenot.interfacesGrouped.fun;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author chloe
|
||||
*/
|
||||
public interface European extends Language, Religion, War {
|
||||
void whatCountry();
|
||||
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Interface.java to edit this template
|
||||
*/
|
||||
package com.chloefontenot.lab8_2_chloefontenot.interfacesGrouped.fun;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author chloe
|
||||
*/
|
||||
public class French implements European
|
||||
{
|
||||
@Override
|
||||
public void whatCountry() {
|
||||
System.out.println("+++ I am from France! +++");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void speakLanguage()
|
||||
{
|
||||
System.out.println("speak French");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void practiceReligion()
|
||||
{
|
||||
System.out.println("Roman Catholic");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void WWI()
|
||||
{
|
||||
System.out.println("In WW1 the French won -- Allies!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void WWII()
|
||||
{
|
||||
System.out.println("In WW2 the French wan -- Allies!");
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
/*
|
||||
* 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.chloefontenot.lab8_2_chloefontenot.interfacesGrouped.fun;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author chloe
|
||||
*/
|
||||
public class German implements European {
|
||||
|
||||
@Override
|
||||
public void whatCountry()
|
||||
{
|
||||
System.out.println("+++ I am from Germany! +++");
|
||||
}
|
||||
@Override
|
||||
public void speakLanguage()
|
||||
{
|
||||
System.out.println("speak German");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void practiceReligion()
|
||||
{
|
||||
System.out.println("Protestant");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void WWI()
|
||||
{
|
||||
System.out.println("in WW1 the Germans lost -- Axis!");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void WWII()
|
||||
{
|
||||
System.out.println("in WW2 the Germans lost -- Axis!");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
/*
|
||||
* 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.chloefontenot.lab8_2_chloefontenot.interfacesGrouped.fun;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author chloe
|
||||
*/
|
||||
public class Italian implements European {
|
||||
|
||||
@Override
|
||||
public void whatCountry()
|
||||
{
|
||||
System.out.println("+++ I am from Itally! +++");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void speakLanguage()
|
||||
{
|
||||
System.out.println("speak Italian");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void practiceReligion()
|
||||
{
|
||||
System.out.println("Roman Catholic");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void WWI()
|
||||
{
|
||||
System.out.println("in WW1 the Italians won -- Allies!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void WWII()
|
||||
{
|
||||
System.out.println("In WW2 the Italians lost -- Axis!");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Interface.java to edit this template
|
||||
*/
|
||||
package com.chloefontenot.lab8_2_chloefontenot.interfacesGrouped.fun;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author chloe
|
||||
*/
|
||||
public interface Language {
|
||||
void speakLanguage();
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Interface.java to edit this template
|
||||
*/
|
||||
package com.chloefontenot.lab8_2_chloefontenot.interfacesGrouped.fun;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author chloe
|
||||
*/
|
||||
public interface Religion {
|
||||
public void practiceReligion();
|
||||
default void beforeChrist() {
|
||||
System.out.println("paganism");
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
/*
|
||||
* 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.chloefontenot.lab8_2_chloefontenot.interfacesGrouped.fun;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author chloe
|
||||
*/
|
||||
public class Russian implements European {
|
||||
|
||||
@Override
|
||||
public void whatCountry()
|
||||
{
|
||||
System.out.println("+++ I am from Russia! +++");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void speakLanguage()
|
||||
{
|
||||
System.out.println("speak Russian");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void practiceReligion()
|
||||
{
|
||||
System.out.println("Orthodox");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void WWI()
|
||||
{
|
||||
System.out.println("In WW1 the Russians won -- Allies!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void WWII()
|
||||
{
|
||||
System.out.println("In WW2 the Russians won -- Allies!");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
/*
|
||||
* 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.chloefontenot.lab8_2_chloefontenot.interfacesGrouped.fun;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author chloe
|
||||
*/
|
||||
public class TestEuropeans {
|
||||
|
||||
public static void testWithArrayList() {
|
||||
ArrayList<European> europeans = new ArrayList();
|
||||
|
||||
europeans.add(new French());
|
||||
europeans.add(new German());
|
||||
europeans.add(new Russian());
|
||||
europeans.add(new Italian());
|
||||
|
||||
for (European man : europeans) {
|
||||
man.whatCountry();
|
||||
man.beforeChrist();
|
||||
man.practiceReligion();
|
||||
man.speakLanguage();
|
||||
man.WWI();
|
||||
man.WWII();
|
||||
}
|
||||
}
|
||||
|
||||
public static void testWithArrayOfObjects() {
|
||||
European[] europeans = {
|
||||
new French(),
|
||||
new German(),
|
||||
new Russian(),
|
||||
new Italian()
|
||||
};
|
||||
for (European person : europeans) {
|
||||
person.whatCountry();
|
||||
person.beforeChrist();
|
||||
person.practiceReligion();
|
||||
person.speakLanguage();
|
||||
person.WWI();
|
||||
person.WWII();
|
||||
}
|
||||
}
|
||||
|
||||
public static void testWithArrayOfInterfaces() {
|
||||
European[] europeans = new European[4];
|
||||
europeans[0] = new French();
|
||||
europeans[1] = new German();
|
||||
europeans[2] = new Russian();
|
||||
europeans[3] = new Italian();
|
||||
|
||||
for (European person : europeans) {
|
||||
person.whatCountry();
|
||||
person.beforeChrist();
|
||||
person.practiceReligion();
|
||||
person.speakLanguage();
|
||||
person.WWI();
|
||||
person.WWII();
|
||||
}
|
||||
}
|
||||
public static void main(String[] args) {
|
||||
testWithArrayList();
|
||||
System.out.println("-------------------");
|
||||
testWithArrayOfObjects();
|
||||
System.out.println("-------------------");
|
||||
testWithArrayOfInterfaces();
|
||||
}
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
/*
|
||||
* 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.chloefontenot.lab8_2_chloefontenot.interfacesGrouped.fun;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author chloe
|
||||
*/
|
||||
public class TestEuropeansAgain {
|
||||
public static void testWithArrayOfInterfaces() {
|
||||
European[] europeans = new European[4];
|
||||
europeans[0] = new French();
|
||||
europeans[1] = new German();
|
||||
europeans[2] = new Russian();
|
||||
europeans[3] = new Italian();
|
||||
|
||||
for (European person : europeans) {
|
||||
person.whatCountry();
|
||||
person.beforeChrist();
|
||||
person.practiceReligion();
|
||||
person.speakLanguage();
|
||||
person.WWI();
|
||||
person.WWII();
|
||||
}
|
||||
}
|
||||
public static void main(String[] args) {
|
||||
testWithArrayOfInterfaces();
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Interface.java to edit this template
|
||||
*/
|
||||
package com.chloefontenot.lab8_2_chloefontenot.interfacesGrouped.fun;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author chloe
|
||||
*/
|
||||
public interface War {
|
||||
void WWI();
|
||||
void WWII();
|
||||
}
|
||||
Reference in New Issue
Block a user