Skip to content
Open

lab3 #123

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
7 changes: 7 additions & 0 deletions lab3/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"java.project.sourcePaths": ["src"],
"java.project.outputPath": "bin",
"java.project.referencedLibraries": [
"lib/**/*.jar"
]
}
18 changes: 18 additions & 0 deletions lab3/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
## Getting Started

Welcome to the VS Code Java world. Here is a guideline to help you get started to write Java code in Visual Studio Code.

## Folder Structure

The workspace contains two folders by default, where:

- `src`: the folder to maintain sources
- `lib`: the folder to maintain dependencies

Meanwhile, the compiled output files will be generated in the `bin` folder by default.

> If you want to customize the folder structure, open `.vscode/settings.json` and update the related settings there.
## Dependency Management

The `JAVA PROJECTS` view allows you to manage your dependencies. More details can be found [here](https://github.com/microsoft/vscode-java-dependency#manage-dependencies).
Binary file added lab3/bin/BigDecimal_Operations/Main.class
Binary file not shown.
Binary file added lab3/bin/Car_Inventory_System/Car.class
Binary file not shown.
Binary file added lab3/bin/Car_Inventory_System/Sedan.class
Binary file not shown.
Binary file added lab3/bin/Car_Inventory_System/Truck.class
Binary file not shown.
Binary file added lab3/bin/Car_Inventory_System/UtilityVehicle.class
Binary file not shown.
Binary file added lab3/bin/IntList_Interface/IntArrayList.class
Binary file not shown.
Binary file added lab3/bin/IntList_Interface/IntList.class
Binary file not shown.
Binary file added lab3/bin/IntList_Interface/IntVector.class
Binary file not shown.
12 changes: 12 additions & 0 deletions lab3/bin/IntList_Interface/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
IntArrayList:

-- using this class is good when you are adding not many elements to the list. because it creates less free slots that will not take much memory

IntVector:

-- this class is good when you need to add more items. it makes less copies and give more slots.


note:
-- if use IntArrayList when you need more slots, then copying of the prev. arrays will fill memory.

Binary file added lab3/bin/Video_Streaming_Service/Movie.class
Binary file not shown.
Binary file added lab3/bin/Video_Streaming_Service/TvSeries.class
Binary file not shown.
Binary file added lab3/bin/Video_Streaming_Service/Video.class
Binary file not shown.
26 changes: 26 additions & 0 deletions lab3/src/BigDecimal_Operations/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package BigDecimal_Operations;
import java.math.BigDecimal;
import java.math.RoundingMode;

public class Main {
public static void main(String[] args) throws Exception {



}

//BigDecimal Operations
//1
public double task1Method(BigDecimal bigD){

return bigD.setScale(2, RoundingMode.HALF_UP).doubleValue();

}

//2 signum() checks if biginteger positive negative or 0
public BigDecimal task2Method(BigDecimal bigD){
BigDecimal result = bigD.setScale(1, RoundingMode.HALF_UP);

return result.negate();
}
}
50 changes: 50 additions & 0 deletions lab3/src/Car_Inventory_System/Car.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package Car_Inventory_System;

public abstract class Car {

private String vinNumber;
private String make;
private String model;
private int mileage;

public String getInfo(){

return "vinNumber is " + this.vinNumber + "\nmake is "+ make
+"\nmodel is " + model+ "\nmileage is "+ mileage;
}


public String getVinNumber() {
return vinNumber;
}

public void setVinNumber(String vinNumber) {
this.vinNumber = vinNumber;
}

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 getMileage() {
return mileage;
}

public void setMileage(int mileage) {
this.mileage = mileage;
}


}
5 changes: 5 additions & 0 deletions lab3/src/Car_Inventory_System/Sedan.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package Car_Inventory_System;

public class Sedan extends Car{

}
16 changes: 16 additions & 0 deletions lab3/src/Car_Inventory_System/Truck.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package Car_Inventory_System;

public class Truck extends Car{

private double towingCapacity;

public double getTowingCapacity() {
return towingCapacity;
}

public void setTowingCapacity(double towingCapacity) {
this.towingCapacity = towingCapacity;
}


}
15 changes: 15 additions & 0 deletions lab3/src/Car_Inventory_System/UtilityVehicle.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package Car_Inventory_System;

public class UtilityVehicle extends Car{

private boolean fourWheelDrive;

public boolean isFourWheelDrive() {
return fourWheelDrive;
}

public void setFourWheelDrive(boolean fourWheelDrive) {
this.fourWheelDrive = fourWheelDrive;
}

}
43 changes: 43 additions & 0 deletions lab3/src/IntList_Interface/IntArrayList.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package IntList_Interface;
//readme.md is in package itself

public class IntArrayList implements IntList {

private int currentIndex = 0;

private int[] array = new int[10];


@Override
public void add(int eded) {

//
if (currentIndex == array.length) {

int[] newarr = new int[(int) (array.length * 1.5)];

for (int i = 0; i < array.length; i++) {
newarr[i] = array[i];

}

array = newarr;
}

array[currentIndex] = eded;
currentIndex++;

}

@Override
public int get(int id) {

if (id >= 0 && id < array.length) {
return array[id];
}
else {
return -1;
}
}

}
12 changes: 12 additions & 0 deletions lab3/src/IntList_Interface/IntList.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package IntList_Interface;

public interface IntList {


void add(int number);

int get(int id);



}
43 changes: 43 additions & 0 deletions lab3/src/IntList_Interface/IntVector.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package IntList_Interface;

public class IntVector implements IntList {

private int currentIndex = 0;

private int[] array = new int[10];


@Override
public void add(int eded) {


if (currentIndex == array.length) {

int[] newarr = new int[array.length * 2];

for (int i = 0; i < array.length; i++) {
newarr[i] = array[i];

}

array = newarr;
}

array[currentIndex] = eded;
currentIndex++;

}

@Override
public int get(int id) {

if (id >= 0 && id < array.length) {
return array[id];
}
else {
return -1;
//
}
}

}
12 changes: 12 additions & 0 deletions lab3/src/IntList_Interface/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
IntArrayList:

-- using this class is good when you are adding not many elements to the list. because it creates less free slots that will not take much memory

IntVector:

-- this class is good when you need to add more items. it makes less copies and give more slots.


note:
-- if use IntArrayList when you need more slots, then copying of the prev. arrays will fill memory.

15 changes: 15 additions & 0 deletions lab3/src/Video_Streaming_Service/Movie.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package Video_Streaming_Service;

public class Movie extends Video{

private double rating;

public double getRating() {
return rating;
}

public void setRating(double rating) {
this.rating = rating;
}

}
15 changes: 15 additions & 0 deletions lab3/src/Video_Streaming_Service/TvSeries.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package Video_Streaming_Service;

public class TvSeries extends Video{

private int episodes;

public int getEpisodes() {
return episodes;
}

public void setEpisodes(int episodes) {
this.episodes = episodes;
}

}
13 changes: 13 additions & 0 deletions lab3/src/Video_Streaming_Service/Video.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package Video_Streaming_Service;

public abstract class Video {

private String title;
private int duration;

public String getInfo(){

return "title is " + this.title + "\nduration"+ duration;

}
}