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
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>
17 changes: 17 additions & 0 deletions Calculator/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?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>
</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
Binary file added Calculator/bin/calculator.class
Binary file not shown.
26 changes: 26 additions & 0 deletions Calculator/src/calculator.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import java.util.Scanner;
public class calculator {

public static void main(String[] args) {
System.out.println("Hello, please provide two numbers.");
System.out.println("Type the first number: ");
Scanner reader = new Scanner (System.in);
int input1 = reader.nextInt();
System.out.println("Type the second number: ");
Scanner reader2 = new Scanner (System.in);
int input2 = reader2.nextInt();
reader.close();
reader2.close();
int sum = input1 + input2;
int diff = input1 - input2;
int product = input1 * input2;
int quo = input1/input2;
System.out.println("The sum is "+ sum);
System.out.println("The diff is "+diff);
System.out.println("The product is "+product);
System.out.println("The quotient is "+quo);
// TODO Auto-generated method stub

}

}
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
23 changes: 23 additions & 0 deletions CarLot/src/Car.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

public class Car extends Vehicle {

private String type;
private int numDoors;

public void printDescription() {

}

public String getType() {
return this.type;
}



public Car(String type, int numDoors,String license,String make,String model, int price) {
super(license, make, model,price);
this.type = type;
this.numDoors = numDoors;
}

}
29 changes: 29 additions & 0 deletions CarLot/src/CarLot.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import java.util.ArrayList;
import java.util.List;

public class CarLot {

private String name;
private List<Vehicle> vehicles;
// private ArrayList vehicleList = new ArrayList();

public CarLot(String name) {
this.name=name;
vehicles = new ArrayList<Vehicle>();
}


public void addVehicle(Vehicle myVehicle) {
vehicles.add(myVehicle);

}

public void printInventory() {
System.out.println("There are " + vehicles.size() + " in car lot" + name);
for (int i=0; i < vehicles.size(); i++) {
vehicles.get(i).printDescription();
}

}

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

public class CarLotProgram {

public static void main(String[] args) {
// Create 2 car lots
CarLot LotOne = new CarLot("Lot 1");
CarLot LotTwo = new CarLot("Lot 2");

Car car1 = new Car("hatchback", 4, "ABCDE23", "Jeep", "Jeep Wrangler", 30000);
Car car2 = new Car("sedan", 4, "BDEFDL2", "Honda", "Accord", 35000);
Truck truck1 = new Truck("large", "IEKDI23", "GM", "Silverado", 35000);
Truck truck2 = new Truck("medium", "83JDJ23", "Dodge", "Ram", 40000);


LotOne.addVehicle(car1);
LotOne.addVehicle(car2);
LotOne.addVehicle(truck1);
LotOne.addVehicle(truck2);

LotTwo.addVehicle(car1);
LotTwo.addVehicle(car2);
LotTwo.addVehicle(truck1);
LotTwo.addVehicle(truck2);

LotOne.printInventory();
LotTwo.printInventory();


}

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

public class Truck extends Vehicle {


private String bedSize;


public Truck(String bedSize,String license, String make, String model, int price) {
super(license, make, model,price);
this.bedSize = bedSize;

}



public void printDescription(){
super.printDescription();
System.out.println("The Bed size of truck: " + bedSize);

}





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

public abstract class Vehicle {

private String licenseNumber;
private String make;
private String model;
private int price;



public Vehicle(String license,String make2, String model2,int price2) {
licenseNumber = license;
make = make2;
model = model2;
price = price2;
// TODO Auto-generated constructor stub
}


public String getLicenseNumber() {
return licenseNumber;
}

public void setLicenseNumber(String mylicenseNumber) {
licenseNumber = mylicenseNumber;
}

public String getMake() {
return make;
}

public void setMake(String mymake) {
make = mymake;
}

public String getModel() {
return model;
}

public void setModel(String mymodel) {
model = mymodel;
}

public int getPrice() {
return price;
}

public void setPrice(int myprice) {
price = myprice;
}

public void printDescription() {
System.out.println("Below is the vehicle's description: ");
System.out.println("This is a " + make + " " + model + ". The current price is " + price + ". License Number is " + licenseNumber + ".");
}

}
6 changes: 6 additions & 0 deletions DriversLicense/.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 DriversLicense/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/bin/
17 changes: 17 additions & 0 deletions DriversLicense/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>DriversLicense</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 DriversLicense/.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 DriversLicense/src/DriversLicense.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import java.util.Date;
import java.time.*;


public class DriversLicense {


public String FirstName;
public String LastName;
public Date DOB;
public String dob;
public String height;
public char gender;


public DriversLicense() {

}

//Methods

//Get Full Name
public String getFullName() {
String name = (FirstName + " " + LastName);
return name;

}

//Get Age
public int getAge() {
LocalDate today = LocalDate.now(); //today's date
String stryear = dob.substring(6); //Gets year isolated
int year = Integer.parseInt(stryear); // Year is no an int

String strmonth = dob.substring(0,2); //Gets month isolated
int month = Integer.parseInt(strmonth); // Month is now an int

String strday = dob.substring(3,5); //Gets day isolated
int day = Integer.parseInt(strday); //Day is now an int

LocalDate birthday = LocalDate.of(year, month, day);
Period period = Period.between(birthday, today);

int age = period.getYears(); // Gets age in years
return age;



// String stryear = dob.substring(6);
// int year = Integer.parseInt(stryear);
// int age = 2018-year;
// return age;
}

public void setDob(String dob) {
this.dob = dob;
}

public void setFirstName(String firstName) {
FirstName = firstName;
}

public void setLastName(String lastName) {
LastName = lastName;
}


}
Loading