From 84d6edaa3415058aad1df2fbfbb925f5f8f78a87 Mon Sep 17 00:00:00 2001 From: Caleb Fontenot Date: Thu, 9 Feb 2023 13:49:46 -0600 Subject: [PATCH] lab3, add HTMLs --- .../Printed HTMLs/FanList.html | 104 ++++++++++++ .../Printed HTMLs/Stock.html | 144 ++++++++++++++++ .../Printed HTMLs/StockList.html | 100 +++++++++++ .../lab3_CalebFontenot/Printed HTMLs/fan.html | 160 ++++++++++++++++++ 4 files changed, 508 insertions(+) create mode 100644 Semester 2/Assignments/lab3_CalebFontenot/Printed HTMLs/FanList.html create mode 100644 Semester 2/Assignments/lab3_CalebFontenot/Printed HTMLs/Stock.html create mode 100644 Semester 2/Assignments/lab3_CalebFontenot/Printed HTMLs/StockList.html create mode 100644 Semester 2/Assignments/lab3_CalebFontenot/Printed HTMLs/fan.html diff --git a/Semester 2/Assignments/lab3_CalebFontenot/Printed HTMLs/FanList.html b/Semester 2/Assignments/lab3_CalebFontenot/Printed HTMLs/FanList.html new file mode 100644 index 0000000..d8a5a05 --- /dev/null +++ b/Semester 2/Assignments/lab3_CalebFontenot/Printed HTMLs/FanList.html @@ -0,0 +1,104 @@ + + + +FanList.java + + + + +
/home/caleb/ASDV-Java/Semester 2/Assignments/lab3_CalebFontenot/src/main/java/com/calebfontenot/lab3_calebfontenot/FanList.java
+
+/*
+ * 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.lab3_calebfontenot;
+
+import java.util.Scanner;
+
+/**
+ *
+ * @author caleb
+ */
+public class FanList {
+
+    private Fan[] list;
+
+    // A constructor that  creates a list of type fan
+    public FanList(int listSize)
+    {
+        list = new Fan[listSize];
+        createListObjects();
+    }
+
+    // Creates a list of Fan objects from User's input
+    private void createListObjects()
+    {
+        Scanner scan = new Scanner(System.in);
+        for (int i = 0; i < list.length; ++i) {
+            Fan fan = new Fan();
+            System.out.println("Enter FAN data for fan " + (i + 1)
+                    + ": color, radius, speed(1, 2 or 3) and if on (t, f)");
+            String color = scan.next();
+            int radius = scan.nextInt();
+            int speed = scan.nextInt();
+            String on = scan.next();
+            fan.setSpeed(speed);
+            fan.setRadius(radius);
+            fan.setColor(color);
+            if ("t".compareToIgnoreCase(on) == 0) {
+                fan.setOn(true);
+            } else {
+                fan.setOn(false);
+            }
+            list[i] = fan;
+            System.out.println("----------------------------------------");
+        }
+    }
+
+    @Override
+    public String toString()
+    {
+        String s = "FanList{" + "list=\n";
+        for (int i = 0; i < list.length; ++i) {
+            s += list[i].toString() + "\n-----------------------\n";
+        }
+        s += '}';
+        return s;
+    }
+
+    public void sortListByRadius()
+    {
+        for (int i = 0; i < list.length - 1; ++i) {
+            for (int j = i + 1; j < list.length; ++j) {
+                if (list[i].getRadius() > list[j].getRadius()) {
+                    Fan temp = list[i];
+                    list[i] = list[j];
+                    list[j] = temp;
+                }
+            }
+        }
+    }
+    public static void main(String[] args)
+    {
+        FanList fanList = new FanList(3);
+        System.out.println(fanList);
+        fanList.sortListByRadius();
+        System.out.println(fanList.toString());
+    }
+}
+
+
+ diff --git a/Semester 2/Assignments/lab3_CalebFontenot/Printed HTMLs/Stock.html b/Semester 2/Assignments/lab3_CalebFontenot/Printed HTMLs/Stock.html new file mode 100644 index 0000000..f8c02f2 --- /dev/null +++ b/Semester 2/Assignments/lab3_CalebFontenot/Printed HTMLs/Stock.html @@ -0,0 +1,144 @@ + + + +Stock.java + + + + +
/home/caleb/ASDV-Java/Semester 2/Assignments/lab3_CalebFontenot/src/main/java/com/calebfontenot/lab3_calebfontenot/Stock.java
+
+/*
+ * 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.lab3_calebfontenot;
+
+/**
+ *
+ * @author caleb
+ */
+public class Stock {
+    
+    private String symbol;
+    private String name;
+    private double previousClosingPrice;
+    private double currentPrice;
+
+    /**
+     * Get the value of currentPrice
+     *
+     * @return the value of currentPrice
+     */
+    public double getCurrentPrice()
+    {
+        return currentPrice;
+    }
+
+    /**
+     * Set the value of currentPrice
+     *
+     * @param currentPrice new value of currentPrice
+     */
+    public void setCurrentPrice(double currentPrice)
+    {
+        this.currentPrice = currentPrice;
+    }
+
+    
+    /**
+     * Get the value of previousClosingPrice
+     *
+     * @return the value of previousClosingPrice
+     */
+    public double getPreviousClosingPrice()
+    {
+        return previousClosingPrice;
+    }
+
+    /**
+     * Set the value of previousClosingPrice
+     *
+     * @param previousClosingPrice new value of previousClosingPrice
+     */
+    public void setPreviousClosingPrice(double previousClosingPrice)
+    {
+        this.previousClosingPrice = previousClosingPrice;
+    }
+
+
+    /**
+     * Get the value of name
+     *
+     * @return the value of name
+     */
+    public String getName()
+    {
+        return name;
+    }
+
+    /**
+     * Set the value of name
+     *
+     * @param name new value of name
+     */
+    public void setName(String name)
+    {
+        this.name = name;
+    }
+
+    /**
+     * Get the value of symbol
+     *
+     * @return the value of symbol
+     */
+    public String getSymbol()
+    {
+        return symbol;
+    }
+
+    /**
+     * Set the value of symbol
+     *
+     * @param symbol new value of symbol
+     */
+    public void setSymbol(String symbol)
+    {
+        this.symbol = symbol;
+    }
+
+    public double getChangePercent() {
+        return this.currentPrice - this.previousClosingPrice;
+        //(((this.previousClosingPrice - this.currentPrice) / Math.abs(this.previousClosingPrice)) * 100)
+    }
+
+    @Override
+    public String toString()
+    {
+        return "Stock{" + "symbol=" + symbol + ", name=" + name + ", previousClosingPrice=" + previousClosingPrice + ", currentPrice=" + currentPrice + "}"+ "\n" + "Change in Percent: " + this.getChangePercent();
+    }
+    public static void main(String[] args)
+    {
+        Stock stock1 = new Stock();
+        stock1.setSymbol("ORCL");
+        stock1.setName("Oracle Corporation");
+        stock1.setPreviousClosingPrice(34.5);
+        stock1.setCurrentPrice(34.35);
+        System.out.println(stock1);
+    }
+}
+
+
+ diff --git a/Semester 2/Assignments/lab3_CalebFontenot/Printed HTMLs/StockList.html b/Semester 2/Assignments/lab3_CalebFontenot/Printed HTMLs/StockList.html new file mode 100644 index 0000000..303f9dd --- /dev/null +++ b/Semester 2/Assignments/lab3_CalebFontenot/Printed HTMLs/StockList.html @@ -0,0 +1,100 @@ + + + +StockList.java + + + + +
/home/caleb/ASDV-Java/Semester 2/Assignments/lab3_CalebFontenot/src/main/java/com/calebfontenot/lab3_calebfontenot/StockList.java
+
+/*
+ * 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.lab3_calebfontenot;
+
+import java.util.Scanner;
+
+/**
+ *
+ * @author caleb
+ */
+public class StockList {
+
+    private Stock[] list;
+
+    // A constructor that  creates a list of type stock
+    public StockList(int listSize)
+    {
+        list = new Stock[listSize];
+        createListObjects();
+    }
+
+    // Creates a list of Fan objects from User's input
+    private void createListObjects()
+    {
+        Scanner scan = new Scanner(System.in);
+        for (int i = 0; i < list.length; ++i) {
+            Stock stock = new Stock();
+            System.out.println("Enter Stock data for stock " + (i + 1)
+                    + ": symbol, name, previous closing price, and current price");
+            String symbol = scan.next();
+            String name = scan.next();
+            double previousClosingPrice = scan.nextDouble();
+            double currentPrice = scan.nextDouble();
+            stock.setSymbol(symbol);
+            stock.setName(name);
+            stock.setPreviousClosingPrice(previousClosingPrice);
+            stock.setCurrentPrice(currentPrice);
+            list[i] = stock;
+            System.out.println("----------------------------------------");
+        }
+    }
+
+    @Override
+    public String toString()
+    {
+        String s = "StockList{" + "list=\n";
+        for (int i = 0; i < list.length; ++i) {
+            s += list[i].toString() + "\n-----------------------\n";
+        }
+        s += '}';
+        return s;
+    }
+
+    public void sortByChangeInPercentage()
+    {
+        for (int i = 0; i < list.length - 1; ++i) {
+            for (int j = i + 1; j < list.length; ++j) {
+                if (list[i].getChangePercent() > list[j].getChangePercent()) {
+                    Stock temp = list[i];
+                    list[i] = list[j];
+                    list[j] = temp;
+                }
+            }
+        }
+    }
+    public static void main(String[] args)
+    {
+        StockList stockList = new StockList(3);
+        System.out.println(stockList);
+        stockList.sortByChangeInPercentage();
+        System.out.println(stockList);
+    }
+}
+
+
+ diff --git a/Semester 2/Assignments/lab3_CalebFontenot/Printed HTMLs/fan.html b/Semester 2/Assignments/lab3_CalebFontenot/Printed HTMLs/fan.html new file mode 100644 index 0000000..e771112 --- /dev/null +++ b/Semester 2/Assignments/lab3_CalebFontenot/Printed HTMLs/fan.html @@ -0,0 +1,160 @@ + + + +Fan.java + + + + +
/home/caleb/ASDV-Java/Semester 2/Assignments/lab3_CalebFontenot/src/main/java/com/calebfontenot/lab3_calebfontenot/Fan.java
+
+/*
+ * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
+ */
+package com.calebfontenot.lab3_calebfontenot;
+
+/**
+ *
+ * @author caleb
+ */
+public class Fan {
+    // Constants
+    public static final int SLOW = 1;
+    public static final int MEDIUM = 2;
+    public static final int FAST = 3;
+    
+    private int speed;
+    private boolean isOn;
+    private int radius;
+    private String color;
+
+    public Fan() {
+        this.speed = 1;
+        this.isOn = false;
+        this.radius = 5;
+        this.color = "blue";
+    }
+    
+    /**
+     * Get the value of color
+     *
+     * @return the value of color
+     */
+    public String getColor()
+    {
+        return color;
+    }
+
+    /**
+     * Set the value of color
+     *
+     * @param color new value of color
+     */
+    public void setColor(String color)
+    {
+        this.color = color;
+    }
+
+    /**
+     * Get the value of radius
+     *
+     * @return the value of radius
+     */
+    public int getRadius()
+    {
+        return radius;
+    }
+
+    /**
+     * Set the value of radius
+     *
+     * @param radius new value of radius
+     */
+    public void setRadius(int radius)
+    {
+        this.radius = radius;
+    }
+
+    /**
+     * Get the value of isOn
+     *
+     * @return the value of isOn
+     */
+    public boolean isOn()
+    {
+        return isOn;
+    }
+
+    /**
+     * Set the value of isOn
+     *
+     * @param isOn new value of isOn
+     */
+    public void setOn(boolean isOn)
+    {
+        this.isOn = isOn;
+    }
+
+    /**
+     * 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;
+    }
+
+    @Override
+    public String toString()
+    {
+        String returnString;
+        if (this.isOn) {
+            returnString = "fan is on. ";
+        }
+        else {
+            returnString = "fan is off. ";
+        }
+        returnString += "{" + "speed=" + speed + ", radius=" + radius + ", color=" + color + '}';
+        return returnString;
+    }
+
+    public static void main(String[] args)
+    {
+        Fan fan1 = new Fan();
+        fan1.setSpeed(Fan.FAST);
+        fan1.setRadius(10);
+        fan1.setColor("yellow");
+        fan1.setOn(true);
+        System.out.println(fan1);
+        
+        Fan fan2 = new Fan();
+        fan2.setSpeed(Fan.MEDIUM);
+        fan2.setRadius(5);
+        fan2.setColor("blue");
+        fan2.setOn(false);
+        System.out.println(fan2.toString());
+    }
+}
+
+
+