Initial Commit

This commit is contained in:
2022-10-07 00:22:46 -03:00
commit bdcf6d3e1c
465 changed files with 15466 additions and 0 deletions

8
Source Code/Assignment7Q1/.idea/.gitignore generated vendored Normal file
View File

@ -0,0 +1,8 @@
# Default ignored files
/shelf/
/workspace.xml
# Datasource local storage ignored files
/../../../../../../:\ProgrammingProjects\JavaProjects\JavaYear1\Assignment7Q1\.idea/dataSources/
/dataSources.local.xml
# Editor-based HTTP Client requests
/httpRequests/

View File

@ -0,0 +1,25 @@
<component name="ProjectCodeStyleConfiguration">
<code_scheme name="Project" version="173">
<JetCodeStyleSettings>
<option name="PACKAGES_TO_USE_STAR_IMPORTS">
<value>
<package name="java.util" alias="false" withSubpackages="false" />
<package name="kotlinx.android.synthetic" alias="false" withSubpackages="true" />
<package name="io.ktor" alias="false" withSubpackages="true" />
</value>
</option>
<option name="PACKAGES_IMPORT_LAYOUT">
<value>
<package name="" alias="false" withSubpackages="true" />
<package name="java" alias="false" withSubpackages="true" />
<package name="javax" alias="false" withSubpackages="true" />
<package name="kotlin" alias="false" withSubpackages="true" />
<package name="" alias="true" withSubpackages="true" />
</value>
</option>
</JetCodeStyleSettings>
<ScalaCodeStyleSettings>
<option name="MULTILINE_STRING_CLOSING_QUOTES_ON_NEW_LINE" value="true" />
</ScalaCodeStyleSettings>
</code_scheme>
</component>

View File

@ -0,0 +1,5 @@
<component name="ProjectCodeStyleConfiguration">
<state>
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
</state>
</component>

View File

@ -0,0 +1 @@
<html>Simple <b>Java</b> application that includes a class with <code>main()</code> method</html>

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="PROJECT" charset="UTF-8" />
</component>
</project>

View File

@ -0,0 +1,10 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="DuplicatedCode" enabled="true" level="WEAK WARNING" enabled_by_default="true">
<Languages>
<language minSize="47" name="Java" />
</Languages>
</inspection_tool>
</profile>
</component>

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectKey">
<option name="state" value="project://e2804f05-5315-4fc6-a121-c522a6c26470" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/Assignment7Q1.iml" filepath="$PROJECT_DIR$/Assignment7Q1.iml" />
</modules>
</component>
</project>

View File

@ -0,0 +1,3 @@
<template>
<input-field default="com.company">IJ_BASE_PACKAGE</input-field>
</template>

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

View File

@ -0,0 +1,57 @@
/**
* This class drives the program, it controls the console input/output and passes arguments given to the classes
* @author Isaac Shoebottom (3429069)
*/
public class Main {
public static void main(String[] args) {
byte userChoice;
double biggestCorralArea = 0;
String biggestCorralType = "not applicable";
java.util.Scanner scan = new java.util.Scanner(System.in);
do {
System.out.print(
"What would you like to do?\n" +
"1 - Get info for rectangular enclosure\n" +
"2 - Get info for polygon enclosure\n" +
"3 - Quit\n" +
"Enter your choice: ");
userChoice = scan.nextByte();
if (userChoice == 1) {
System.out.print("Width in meters: ");
double tempWidth = scan.nextDouble();
System.out.print("Length in meters: ");
double tempLength = scan.nextDouble();
RectangularCorral corral = new RectangularCorral(tempWidth, tempLength);
System.out.print("The area is: "); System.out.printf("%.3f", corral.getArea()); System.out.print(" square meters\n");
System.out.print("The cost is: "); System.out.printf("%.2f", corral.getTotalFenceCost()); System.out.print("$\n");
if (biggestCorralArea < corral.getArea()) {
biggestCorralArea = corral.getArea();
biggestCorralType = "rectangle";
}
}
if (userChoice == 2) {
System.out.print("Length of sides: ");
double tempLength = scan.nextDouble();
System.out.print("Number of sides: ");
long tempSides = scan.nextLong();
PolygonalCorral corral = new PolygonalCorral(tempLength, tempSides);
System.out.print("The area is: "); System.out.printf("%.3f", corral.getArea()); System.out.print(" square meters\n");
System.out.print("The cost is: "); System.out.printf("%.2f", corral.getTotalFenceCost()); System.out.print("$\n");
if (biggestCorralArea < corral.getArea()) {
biggestCorralArea = corral.getArea();
biggestCorralType = "polygon";
}
}
} while (userChoice != 3);
System.out.println("The corral with the largest area is a " + biggestCorralType);
System.out.print("It's area is : "); System.out.printf("%.3f", biggestCorralArea); System.out.print(" square meters");
}
}

View File

@ -0,0 +1,72 @@
/**
* This class describes a polygonal corral with each side of equal length. It takes a length and a number of sides.
* @author Isaac Shoebottom (3429069)
*/
public class PolygonalCorral {
/**
* The unit price is how much the fence costs per meter
*/
final double unitPrice = 9.50;
/**
* The length is how long each side of the polygonal corral is in meters
*/
double length;
/**
* The number of sides in the polygonal corral
*/
long numberOfSides;
/**
* The polygonal corral method contains the length and number of sides
* @param length The length of the sides of the polygonal corral in meters
* @param numberOfSides The number of sides of the polygonal corral
*/
PolygonalCorral (double length, long numberOfSides) {
this.length = length;
this.numberOfSides = numberOfSides;
}
/**
* Method to get the length of the polygonal corrals sides
* @return The length of the corrals sides in meters
*/
public double getLength() {
return length;
}
/**
* Method to get the number of sides of the polygonal corral
* @return The number of sides of the polygonal corral
*/
public long getNumberOfSides() {
return numberOfSides;
}
/**
* Method to get the unit price of a meter of fence
* @return The price of a meter of fence
*/
public double getUnitPrice() {
return unitPrice;
}
/**
* Method to get the total cost of the polygonal fence
* @return The cost of the polygonal fence
*/
public double getTotalFenceCost() {
return (length*numberOfSides*unitPrice);
}
/**
* Method to get the area of the polygonal corral
* @return The area of the polygonal corral in meters squared
*/
public double getArea() {
double radians = (180/(double)numberOfSides)*(Math.PI/180);
double apothem = length/(2*Math.tan(radians));
return (0.5*(length*numberOfSides)*apothem);
}
}

View File

@ -0,0 +1,69 @@
/**
* This class describes a rectangular corral with a width and length
* @author Isaac Shoebottom (3429069)
*/
public class RectangularCorral {
/**
* The width of the rectangular corral
*/
double width;
/**
* The length of the rectangular corral
*/
double length;
/**
* The price of fence per meter
*/
final double unitPrice = 9.50;
/**
* The rectangular corral method contains the width and the height of the corral
* @param width The width of the rectangular corral
* @param length The length of the rectangular corral
*/
RectangularCorral (double width, double length) {
this.width = width;
this.length = length;
}
/**
* Method to get the length of the rectangular corral
* @return The length of the rectangular corral
*/
public double getLength() {
return length;
}
/**
* Method to get the width of the rectangular corral
* @return The width of the rectangular corral
*/
public double getWidth() {
return width;
}
/**
* Method to get the price of fence per meter
* @return The price of fence per meter
*/
public double getUnitPrice() {
return unitPrice;
}
/**
* Method to get the total cost of the rectangular fence
* @return The total cost of the rectangular fence
*/
public double getTotalFenceCost() {
return ((length+width)*2*unitPrice);
}
/**
* Method to get the area of a rectangular corral
* @return The area of a rectangular corral
*/
public double getArea() {
return (length*width);
}
}