Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/.metadata/
/.recommenders/
6 changes: 6 additions & 0 deletions Calculator/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
13 changes: 13 additions & 0 deletions Calculator/.dbeaver-data-sources.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<data-sources>
<data-source id="sqlite_jdbc-1693b5fdfbb-3766dd9cb174c7fc" provider="generic" driver="sqlite_jdbc" name="SQLite - spring-app.db" save-password="true" read-only="false">
<connection server="" database="C:\Users\Patricia_parnell\spring-app\spring-app.db" url="jdbc:sqlite:C:\Users\Patricia_parnell\spring-app\spring-app.db" type="dev"/>
</data-source>
<data-source id="sqlite_jdbc-16941e945d3-641db2cc7b145c87" provider="generic" driver="sqlite_jdbc" name="SQLite - sample.db" save-password="true" read-only="false">
<connection server="" database="C:\Users\Patricia_parnell\dell-java\FinalProject\sample.db" url="jdbc:sqlite:C:\Users\Patricia_parnell\dell-java\FinalProject\sample.db" type="dev"/>
</data-source>
<data-source id="sqlite_jdbc-16941ea0426-5a29db5f1db216f7" provider="generic" driver="sqlite_jdbc" name="SQLite - sample.db 2" save-password="true" read-only="false">
<connection server="" database="C:\Users\Patricia_parnell\dell-java\FinalProject\sample.db" url="jdbc:sqlite:C:\Users\Patricia_parnell\dell-java\FinalProject\sample.db" type="dev"/>
</data-source>
<filters/>
</data-sources>
1 change: 1 addition & 0 deletions Calculator/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/bin/
18 changes: 18 additions & 0 deletions Calculator/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Calculator</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.jkiss.dbeaver.DBeaverNature</nature>
</natures>
</projectDescription>
11 changes: 11 additions & 0 deletions Calculator/.settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.8
68 changes: 68 additions & 0 deletions Calculator/src/Calculator.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import java.util.Scanner;

public class Calculator {


public static void main(String[] args) {
float firstNbr = 0;
float secondNbr = 0;

// TODO Auto-generated method stub
System.out.println("Welcome to the calculator!");
System.out.println("Enter in your first number: ");
Scanner reader = new Scanner(System.in);
firstNbr = reader.nextFloat();
System.out.println("Enter in your second number: ");
secondNbr = reader.nextFloat();

printer (firstNbr,secondNbr );


reader.close();

}

public static float add (float first , float second) {
return first + second;
}

public static float subtract (float first , float second) {
return first - second;
}

public static float multiply (float first , float second) {
return first * second;
}

public static float divide (float first , float second) {
return first / second;
}

public static float modulus (float first , float second) {
return first % second;
}

public static void printer (float first, float second) {
float result = 0;

System.out.println("Your first number is: " + first);
System.out.println("Your second number is: " + second);

result = add(first,second) ;
System.out.println("Addition: " + first + " + " + second + " = " + result);

result = subtract(first,second) ;
System.out.println("Subtraction: " + first + " - " + second + " = " + result);

result = multiply(first,second) ;
System.out.println("Multiplication: " + first + " * " + second + " = " + result);

result = divide(first,second) ;
System.out.println("Division: " + first + " / " + second + " = " + result);

result = modulus(first,second) ;
System.out.println("Remainder: The remainder of " + first + " / " + second + " is " + result);


}
}
6 changes: 6 additions & 0 deletions CarLot/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
1 change: 1 addition & 0 deletions CarLot/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/bin/
17 changes: 17 additions & 0 deletions CarLot/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>CarLot</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
11 changes: 11 additions & 0 deletions CarLot/.settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.8
38 changes: 38 additions & 0 deletions CarLot/src/Car.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@

public class Car extends Vehicle {
//variables for class car
private String type;
private Integer doorNumber;


//constructor for car
public Car(String licenseNbr, String make, String model, Double price, String type, Integer doorNumber) {
super(licenseNbr, make, model, price); //call to constructor for abstract class vehicles
this.type = type;
this.doorNumber = doorNumber;
}

//getters and setters for car
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public Integer getDoorNumber() {
return doorNumber;
}
public void setDoorNumber(Integer doorNumber) {
this.doorNumber = doorNumber;
}

public void printVehicleDescription() {
//print routine for car.
//first calls print routine for abstract class vehicle.

super.printVehicleDescription();
System.out.println("Type: " + this.getType());
System.out.println("Number of Doors: " + this.getDoorNumber());
System.out.println("");
}
}
62 changes: 62 additions & 0 deletions CarLot/src/CarLot.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

public class CarLot {
//declare variables for carlot name and list of vehicles
private String carLotName;
private ArrayList <Vehicle> alVehicleList = new ArrayList<Vehicle>(); //using an array list

//constructor for car lot
public CarLot(String carLotName) {
this.carLotName = carLotName;
}

//getters and setters for carlot
public ArrayList<Vehicle> getAlVehicleList() {
return alVehicleList;
}
public void setAlVehicleList(Vehicle myVehicle) {
//this setting is just taking in 1 vehicle and
//adding it to the array list
this.alVehicleList.add(myVehicle);
}
public String getCarLotName() {
return carLotName;
}
public void setCarLotName(String carLotName) {
this.carLotName = carLotName;
}


public void printInventory () {
//prints our car lots inventory

System.out.println("**********Car Lot Name: " + this.getCarLotName() + " Inventory List **********");

for (int i = 0; i < alVehicleList.size(); i++) {
// loop for each vehicle in array

if (alVehicleList.get(i) instanceof Truck ) {
//prints Truck attributes for trucks
((Truck)alVehicleList.get(i)).printVehicleDescription();
}
else {
//prints Car attributes for cars.
((Car)alVehicleList.get(i)).printVehicleDescription();
}

}

System.out.println("**********End " + this.getCarLotName() + " Inventory List **********");
System.out.println("");
System.out.println("");



}




}
38 changes: 38 additions & 0 deletions CarLot/src/CarLotProgram.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@

public class CarLotProgram {

public static void main(String[] args) {
//declaring 2 car lots passing in the name
CarLot NorthValley = new CarLot("North Valley");
CarLot BlueBonnect = new CarLot("Blue Bonnet");

//creating cars and trucks passing in attributes for vehicle + specific attributes
//specific to type car or truck
Car BlueHonda = new Car ("abc123", "Honda", "Accord", 20000.10, "Sedan", 4);
Car RedInfinity = new Car ("zzz343", "Infinity", "300", 12000.10, "Coupe", 2);
Car MonteCarlo = new Car ("zzz89", "Chevy", "MonteCarlo", 10000.10, "Coupe", 2);
Car Nissan = new Car ("2233zz", "Nissan", "Altima", 12000.10, "Sedan", 2);
Car Ford = new Car ("aabb11", "Ford", "Neo", 14000.10, "Hatchback", 3);

Truck FordF150 = new Truck ("abx911", "Ford", "F150", 16000.10, "short");
Truck Fordf20 = new Truck ("dfx921", "Ford", "F250", 26000.10, "long");
Truck NissanTundra = new Truck ("jhx911", "Nissan", "Tundra", 14200.10, "medium");


//adding vehicles to each carlot
NorthValley.setAlVehicleList(BlueHonda);
NorthValley.setAlVehicleList(MonteCarlo);
NorthValley.setAlVehicleList(Ford);
NorthValley.setAlVehicleList(FordF150);

BlueBonnect.setAlVehicleList(RedInfinity);
BlueBonnect.setAlVehicleList(Fordf20);
BlueBonnect.setAlVehicleList(NissanTundra);
BlueBonnect.setAlVehicleList(Nissan);

//printing each inventory
NorthValley.printInventory();
BlueBonnect.printInventory();
}

}
32 changes: 32 additions & 0 deletions CarLot/src/Truck.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@

public class Truck extends Vehicle {
//variables for class Truck
private String bedSize;

//constructor for car
public Truck(String licenseNbr, String make, String model, Double price, String bedSize) {
super(licenseNbr, make, model, price);
this.bedSize = bedSize;
}

//getters and setters for truck
public String getBedSize() {
return bedSize;
}

public void setBedSize(String bedSize) {
this.bedSize = bedSize;
}


public void printVehicleDescription() {
//print routine for car.
//first calls print routine for abstract class vehicle.

super.printVehicleDescription();
System.out.println("Bed size: " + this.getBedSize());
System.out.println("");

}

}
54 changes: 54 additions & 0 deletions CarLot/src/Vehicle.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@

public abstract class Vehicle {
//declaration for abstract class

//variables for abstract class vehicle
private String licenseNbr;
private String make;
private String model;
private Double price;


//constructor for abstract class vehicles
public Vehicle(String licenseNbr, String make, String model, Double price) {
this.licenseNbr = licenseNbr;
this.make = make;
this.model = model;
this.price = price;
}

//getters and setters for the class
public String getLicenseNbr() {
return licenseNbr;
}
public void setLicenseNbr(String licenseNbr) {
this.licenseNbr = licenseNbr;
}
public String getMake() {
return make;
}
public void setMake(String make) {
this.make = make;
}
public String getModel() {
return model;
}
public void setModel(String model) {
this.model = model;
}
public Double getPrice() {
return price;
}
public void setPrice(Double price) {
this.price = price;
}


public void printVehicleDescription() {
//print method for class vehicle. called from any subclasses.
System.out.println("Make: " + this.getMake());
System.out.println("Model: " + this.getModel());
System.out.println("License Number: " + this.getLicenseNbr());
System.out.println("Price: " + String.format ( "$ %(,.2f", this.getPrice()));
}
}
Loading