lab8_2
This commit is contained in:
14
Semester 2/Assignments/AbstractMethod/pom.xml
Normal file
14
Semester 2/Assignments/AbstractMethod/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>AbstractMethod</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<exec.mainClass>com.calebfontenot.abstractmethod.AbstractMethod</exec.mainClass>
|
||||
</properties>
|
||||
</project>
|
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
*/
|
||||
|
||||
package com.calebfontenot.abstractmethod;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
*/
|
||||
public class AbstractMethod {
|
||||
}
|
||||
public abstract class A {
|
||||
abstract void f1();
|
||||
public static void main(String[] args)
|
||||
{
|
||||
A a = new B();
|
||||
b.f1();
|
||||
//A a = new B();
|
||||
a.f1();
|
||||
D d = new D();
|
||||
d.f1();
|
||||
d.f2();
|
||||
A[] a1 = new A[3];
|
||||
A[] a1= new A[2];
|
||||
}
|
||||
}
|
||||
|
||||
class B extends A {
|
||||
@Override
|
||||
void f1() {
|
||||
System.out.println("f1");
|
||||
}
|
||||
}
|
||||
|
||||
class C extends A {
|
||||
@Override
|
||||
void f2() {
|
||||
System.out.println("f2");
|
||||
}
|
||||
}
|
||||
|
||||
class D extends C {
|
||||
void f3() {
|
||||
System.out.println("f3");
|
||||
}
|
||||
}
|
||||
|
||||
abstract class E extends B {
|
||||
@Override
|
||||
void f1() {
|
||||
System.out.println("f1");
|
||||
}
|
||||
@Override
|
||||
void x() {
|
||||
System.out.println("x");
|
||||
}
|
||||
}
|
||||
abstract class F extends A {
|
||||
@Override
|
||||
void f1() {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
@Override
|
||||
abstract void x();
|
||||
}
|
||||
}
|
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* 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.abstractmethod;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
*/
|
||||
import java.util.ArrayList;
|
||||
import java.math.*;
|
||||
|
||||
public class LargestNumbers {
|
||||
public static void main(String[] args) {
|
||||
ArrayList<Number> list = new ArrayList<Number>();
|
||||
list.add(45); // Add an integer
|
||||
list.add(3445.53); // Add a double
|
||||
// Add a BigInteger
|
||||
list.add(new BigInteger("3432323234344343101"));
|
||||
// Add a BigDecimal
|
||||
list.add(new BigDecimal("2.0909090989091343433344343"));
|
||||
|
||||
System.out.println("The largest number is " +
|
||||
getLargestNumber(list));
|
||||
}
|
||||
|
||||
public static Number getLargestNumber(ArrayList<Number> list) {
|
||||
if (list == null || list.size() == 0)
|
||||
return null;
|
||||
|
||||
Number number = list.get(0);
|
||||
for (int i = 1; i < list.size(); i++)
|
||||
if (number.doubleValue() < list.get(i).doubleValue())
|
||||
number = list.get(i);
|
||||
|
||||
return number;
|
||||
}
|
||||
}
|
@@ -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.abstractmethod;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
*/
|
||||
import java.util.*;
|
||||
|
||||
public class TestCalendar {
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
// Construct a Gregorian calendar for the current date and time
|
||||
Calendar calendar = new GregorianCalendar();
|
||||
System.out.println("Current time is " + new Date());
|
||||
System.out.println("YEAR: " + calendar.get(Calendar.YEAR));
|
||||
System.out.println("MONTH: " + calendar.get(Calendar.MONTH));
|
||||
System.out.println("DATE: " + calendar.get(Calendar.DATE));
|
||||
System.out.println("HOUR: " + calendar.get(Calendar.HOUR));
|
||||
System.out.println("HOUR_OF_DAY: "
|
||||
+ calendar.get(Calendar.HOUR_OF_DAY));
|
||||
System.out.println("MINUTE: " + calendar.get(Calendar.MINUTE));
|
||||
System.out.println("SECOND: " + calendar.get(Calendar.SECOND));
|
||||
System.out.println("DAY_OF_WEEK: "
|
||||
+ calendar.get(Calendar.DAY_OF_WEEK));
|
||||
System.out.println("DAY_OF_MONTH: "
|
||||
+ calendar.get(Calendar.DAY_OF_MONTH));
|
||||
System.out.println("DAY_OF_YEAR: "
|
||||
+ calendar.get(Calendar.DAY_OF_YEAR));
|
||||
System.out.println("WEEK_OF_MONTH: "
|
||||
+ calendar.get(Calendar.WEEK_OF_MONTH));
|
||||
System.out.println("WEEK_OF_YEAR: "
|
||||
+ calendar.get(Calendar.WEEK_OF_YEAR));
|
||||
System.out.println("AM_PM: " + calendar.get(Calendar.AM_PM));
|
||||
|
||||
// Construct a calendar for September 11, 2001
|
||||
Calendar calendar1 = new GregorianCalendar(2001, 8, 11);
|
||||
String[] dayNameOfWeek = {"Sunday", "Monday", "Tuesday", "Wednesday",
|
||||
"Thursday", "Friday", "Saturday"};
|
||||
System.out.println("September 11, 2001 is a "
|
||||
+ dayNameOfWeek[calendar1.get(Calendar.DAY_OF_WEEK) - 1]);
|
||||
System.out.println(calendar1.get(Calendar.MONTH));
|
||||
}
|
||||
}
|
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.
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,2 @@
|
||||
/home/caleb/ASDV-WebDev/Assignments/JavaScript/AbstractMethod/src/main/java/com/calebfontenot/abstractmethod/LargestNumbers.java
|
||||
/home/caleb/ASDV-WebDev/Assignments/JavaScript/AbstractMethod/src/main/java/com/calebfontenot/abstractmethod/AbstractMethod.java
|
Reference in New Issue
Block a user