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/Assignment3Q1/.idea/.gitignore generated vendored Normal file
View File

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

1
Source Code/Assignment3Q1/.idea/.name generated Normal file
View File

@ -0,0 +1 @@
Assignment3Q1

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,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" 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$/Assignment3Q1.iml" filepath="$PROJECT_DIR$/Assignment3Q1.iml" />
</modules>
</component>
</project>

View File

@ -0,0 +1,11 @@
<?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,80 @@
/**
This class represents a car.
@author
*/
public class Car {
/**
The model of the car (e.g. "Hyundai Accent").
*/
/**
The fuel efficiency of the car (in liters/100 km).
*/
/**
The amount of gas in the tank (in liters).
*/
/**
This method constructs a car with the specified model and fuel efficiency.
The gas tank is initially empty.
@param modelIn the model of the car.
@param fuelEfficiencyIn the fuel efficiency of the car (in liters/100 km).
*/
/**
This method retrieves the model of the car.
@return the model of the car.
*/
/**
This method retrieves the fuel efficiency of the car.
@return the fuel efficiency of the car (in liters/100 km).
*/
/**
This method retrieves the amount of gas in the tank.
@return the amount of gas in the tank (in litres).
*/
/**
This method drives the car for a certain distance, reducing the gas in the tank.
You may assume that the car will never consume more than the available gas
(you do NOT need to include a check for this in your solution).
@param distance the distance driven (in km).
*/
/**
This method adds gas to the tank.
@param gasAdded the volume of gas added to the tank (in liters).
*/
} //end Car

View File

@ -0,0 +1,8 @@
car1:
Model: 2020 Honda Civic LX Automatic
Fuel Efficiency: 7.1 L/100km
Gas Left: 34.6312 L
car2:
Model: 2020 Ford F-150 XLT Automatic
Fuel Efficiency: 10.7 L/100km
Gas Left: 75.56384 L

View File

@ -0,0 +1,94 @@
/**
This class represents a car.
@author Isaac Shoebottom (3429069)
*/
public class Car {
/**
The model of the car (e.g. "Hyundai Accent").
*/
private final String model;
/**
The fuel efficiency of the car (in liters/100 km).
*/
private final double fuelEfficiency;
/**
The amount of gas in the tank (in liters).
*/
private double tankFilledVolume;
/**
This method constructs a car with the specified model and fuel efficiency.
The gas tank is initially empty.
@param modelIn the model of the car.
@param fuelEfficiencyIn the fuel efficiency of the car (in liters/100 km).
*/
public Car(String modelIn, double fuelEfficiencyIn){
this.model = modelIn;
this.fuelEfficiency = fuelEfficiencyIn;
this.tankFilledVolume = 0;
}
/**
This method retrieves the model of the car.
@return the model of the car.
*/
public String getModel(){
return model;
}
/**
This method retrieves the fuel efficiency of the car.
@return the fuel efficiency of the car (in liters/100 km).
*/
public double getFuelEfficiency(){
return fuelEfficiency;
}
/**
This method retrieves the amount of gas in the tank.
@return the amount of gas in the tank (in litres).
*/
public double getTankVolume(){
return tankFilledVolume;
}
/**
This method drives the car for a certain distance, reducing the gas in the tank.
You may assume that the car will never consume more than the available gas
(you do NOT need to include a check for this in your solution).
@param distance the distance driven (in km).
*/
public void driveCar(double distance){
tankFilledVolume = tankFilledVolume - ((distance/100) * fuelEfficiency);
}
/**
This method adds gas to the tank.
@param gasAdded the volume of gas added to the tank (in liters).
*/
public void addGas(double gasAdded){
tankFilledVolume =+ gasAdded;
}
} //end Car

View File

@ -0,0 +1,29 @@
/**
@author Isaac Shoebottom (3429069)
**/
public class CarDriver {
public static void main(String[] args){
driveCars();
}
private static void driveCars(){
Car car1 = new Car("2020 Honda Civic LX Automatic", 7.1);
Car car2 = new Car("2020 Ford F-150 XLT Automatic", 10.7);
car1.addGas(46.9);
car2.addGas(87.0);
car1.driveCar(172.8);
car2.driveCar(106.88);
System.out.println("car1:" +
"\n Model: " + car1.getModel() +
"\n Fuel Efficiency: " + car1.getFuelEfficiency() + " L/100km" +
"\n Gas Left: " + car1.getTankVolume() + " L");
System.out.println("car2:" +
"\n Model: " + car2.getModel() +
"\n Fuel Efficiency: " + car2.getFuelEfficiency() + " L/100km" +
"\n Gas Left: " + car2.getTankVolume() + " L");
}
}