Skip to content

seri akhar :) #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
34 changes: 34 additions & 0 deletions Car.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import java.util.*;
public class Car {
public static void main(String[] args) {
Queue<String> carQueue = new LinkedList<>();

enqueue(carQueue, "landcruiser");
enqueue(carQueue, "porsche");
enqueue(carQueue, "hilux");
enqueue(carQueue, "lexus lc");

printQueueContents(carQueue);

while (!carQueue.isEmpty()) {
String removedCar = dequeue(carQueue);
System.out.println(removedCar+" Removed ");
}

if (carQueue.isEmpty()) {
System.out.println("The queue is empty.");
} else {
System.out.println("The queue is not empty.");
}
}
public static void enqueue(Queue<String> queue, String car) {
queue.add(car);
}
public static String dequeue(Queue<String> queue) {
return queue.poll();
}
public static void printQueueContents(Queue<String> queue) {
System.out.println("The queue: " + queue);
}
}

9 changes: 7 additions & 2 deletions Detective.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,15 @@ public static void main(String[] args) {

// Print the size of each ArrayList below:


System.out.println(poirotsToDos.size());
System.out.println(sherlocksToDos.size());

// Print the name of the detective with the larger to-do list:

if (poirotsToDos.size() > sherlocksToDos.size()){
System.out.println("Poirot");
}else {
System.out.println("Holmes");
}
}

}
17 changes: 14 additions & 3 deletions HashCollisionChecker.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,23 @@
public class HashCollisionChecker {
public static <T> int countOfUniqueHashCodes(HashSet<T> set) {
// TODO: Implement
return 0;
}
Set<Integer> hashcode = new HashSet<Integer>();
for(T i : set){
hashcode.add(i.hashCode());

}
return hashcode.size();

}

public static <K, V> int countOfUniqueHashCodes(HashMap<K, V> map) {
// TODO: Implement
return 0;
HashSet<Integer> hashcode = new HashSet<>();
for(K i : map.keySet()){
hashcode.add(i.hashCode());

}
return hashcode.size();
}

public static void main(String[] args) {
Expand Down
17 changes: 17 additions & 0 deletions Shaffel.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import java.util.*;
public class Shaffel {
public static void main(String[] args){
LinkedList<Object> linkedList = new LinkedList<>();
Scanner input=new Scanner(System.in);
int number=input.nextInt();
for (int i = 0; i < number; i++) {
String in = input.next();
linkedList.add(in);
}
System.out.println( linkedList);
Collections.shuffle(linkedList);
System.out.println( linkedList);

}
}

77 changes: 77 additions & 0 deletions Uni.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import java.util.*;

class Vorodi implements Comparable<Vorodi> {
private String name;
private int code;
private double moadel;

public void setName(String n) {
this.name = n;
}

public String getName() {
return name;
}

public void setCode(int c) {
this.code = c;
}

public int getCode() {
return code;
}

public void setMoadel(double m) {
this.moadel = m;
}

public double getMoadel() {
return moadel;
}

public int compareTo(Vorodi other) {
return Integer.compare(this.code, other.code);
}

public Vorodi(String n, int c, double m) {
setName(n);
setCode(c);
setMoadel(m);
}

public String d() {
return ("[" + getName() + "," + getCode() + "," + getMoadel() + "]");
}
}

public class Uni {
public static void main(String[]args) {
TreeSet<Vorodi> studentSet = new TreeSet<>();
Scanner s = new Scanner(System.in);
int tedad = s.nextInt();


for (int i = 0; i < tedad; i++) {
String n = s.next();
int c = s.nextInt();
double m = s.nextDouble();
Vorodi student = new Vorodi(n, c, m);
studentSet.add(student);
}

int searchId = s.nextInt();
boolean found = false;
for (Vorodi i : studentSet) {
if (searchId == i.getCode()) {
System.out.println("Student Found");
System.out.println("name :" + i.getName() + "\nId : " + i.getCode() + "\nmoadel :" + i.getMoadel());
found = true;
}
}

if (!found) {
System.out.println("Student not Found");
}
}

}