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

public class Caculator {

public static void main(String[] args) {
// Ask the user for 2 numbers.
// Print out the sum of the 2 numbers.
// Print out the difference of the 2 numbers.
// Print out the product of the 2 numbers.
// Print out the quotient of the 2 numebrs.
// Guidelines:
//
// Your program should implement the operations as different methods
// The methods should take in 2 numbers as input
// The methods should return a single number as the return value
int firstnum = 0;
int secondnum = 0;
System.out.println("Welcome to Caculator");
System.out.println("Please enter your first number.\n");
Scanner reader = new Scanner(System.in);
firstnum = reader.nextInt();
System.out.println("Please enter your Second number.\n");
secondnum = reader.nextInt();

System.out.println(firstnum + " + " + secondnum + " = " + Add(firstnum, secondnum));

System.out.println(firstnum + " - " + secondnum + " = " + Subt(firstnum, secondnum));

System.out.println(firstnum + " x " + secondnum + " = " + Multi(firstnum, secondnum));

System.out.println(
firstnum + " / " + secondnum + " = " + Div(firstnum, secondnum) + "." + Mod(firstnum, secondnum));
reader.close();
}

public static int Add(int firstnum, int secondnum) {
int result = 0;
result = firstnum + secondnum;
return result;
}

public static int Subt(int firstnum, int secondnum) {

int result = 0;
result = firstnum - secondnum;
return result;
}

public static int Multi(int firstnum, int secondnum) {

int result = 0;
result = firstnum * secondnum;
return result;
}

public static int Div(int firstnum, int secondnum) {

int result = 0;
result = firstnum / secondnum;
return result;
}

public static int Mod(int firstnum, int secondnum) {

int result = 0;
result = firstnum % secondnum;
return 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
51 changes: 51 additions & 0 deletions CarLot/src/Car.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@

public class Car extends Vehicle {
//attributes
private String type;
private int numDoors;

//constructor
public Car() {

}

public Car(String licenseNum, String make, String model, int price, String type, int numDoors) {
this.setLicenseNumber(licenseNum);
this.setMake(make);
this.setModel(model);
this.setPrice(price);
this.setType(type);
this.setNumDoors(numDoors);

}

//getters setters
public String getType() {
return type;
}

public void setType(String type) {
this.type = type;
}

public int getNumDoors() {
return numDoors;
}

public void setNumDoors(int numDoors) {
this.numDoors = numDoors;
}

public void printDescription() {
//
System.out.println("Make: " + this.getMake());
System.out.println("Model: "+ this.getModel());
System.out.println("License Number:" + this.getLicenseNumber());
System.out.println("Price: " + this.getPrice());
System.out.println("Type: " + this.getType());
System.out.println("Number of Doors: " + this.numDoors);
}



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

public class CarLot {
//attributes
private String carLotName;
private List<Vehicle> vehiclesList = new ArrayList<Vehicle>();

//constructors
public CarLot() {

}

//getters setters
public String getCarLotName() {
return carLotName;
}

public void setCarLotName(String carLotName) {
this.carLotName = carLotName;
}

public List<Vehicle> getVehiclesList() {
return vehiclesList;
}


public void setVehiclesList(List<Vehicle> vehiclesList) {
this.vehiclesList = vehiclesList;
}

//Methods
public void addtoLot(Vehicle myvehicle) {
//code to add to the list here
vehiclesList.add(myvehicle);
}

public void printInventory() {
//code to print inventory.
System.out.println(carLotName + " vehicle report.");
System.out.println("...This lot currently contains " + vehiclesList.size() + " vehicles.");
System.out.println();
for (int i = 0; i < vehiclesList.size(); i++) {
vehiclesList.get(i).printDescription();
System.out.println();
}
}


}
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) {

Truck truck1 = new Truck("BR549", "Ford", "F150", 55000, 16);
Truck truck2 = new Truck("9999123", "Chevy", "Silverado", 25000, 10);
Truck truck3 = new Truck("9999123", "Chevy", "Silverado", 25000, 10);
Car car1 = new Car("xya345", "Mazda", "626", 125000,"sedan", 4);
Car car2 = new Car("FastCar", "Chevy", "Corvet", 325000,"coupe", 2);
Car car3 = new Car("ABCEr", "Ford", "Fiesta", 5000,"Hatchback", 3);


CarLot lot1 = new CarLot();
lot1.setCarLotName("Great Car Lot");
lot1.addtoLot(truck1);
lot1.addtoLot(truck2);
lot1.addtoLot(car1);

CarLot lot2 = new CarLot();
lot2.setCarLotName("The Best Car Lot");
lot2.addtoLot(car2);
lot2.addtoLot(truck3);
lot2.addtoLot(car3);

lot1.printInventory();
lot2.printInventory();

}

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

public class Truck extends Vehicle {
//Attributes
private int bedSize;

//Constructors
public Truck() {

}
public Truck(String licenseNum, String make, String model, int price,int bed) {
this.setLicenseNumber(licenseNum);
this.setMake(make);
this.setModel(model);
this.setPrice(price);
this.setBedSize(bed);
}


public int getBedSize() {
return bedSize;
}

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


public void printDescription() {
// include bed size in this description
System.out.println("Make: " + this.getMake());
System.out.println("Model: "+ this.getModel());
System.out.println("License Number:" + this.getLicenseNumber());
System.out.println("Price: " + this.getPrice());
System.out.println("Bed Size: " + this.getBedSize());
}

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

public abstract class Vehicle {

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

//no constructors

//getters setters
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 int getPrice() {
return price;
}

public void setPrice(int price) {
this.price = price;
}

public String getLicenseNumber() {
return licenseNumber;
}

public void setLicenseNumber(String licenseNumber) {
this.licenseNumber = licenseNumber;
}

//abstract methods
public abstract void printDescription();

//non abstract methods


}
6 changes: 6 additions & 0 deletions Dog/.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 Dog/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/bin/
17 changes: 17 additions & 0 deletions Dog/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Dog</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>
Loading