EX 6.1 ) Investigate examples of the week EX6.2 ) TreeMap2.java is

advertisement
WEEK 6(chapter 14) CLASS EXERSIZES (Wil be shown at the and of Lab class)
EX 6.1 ) Investigate examples of the week
Required class
Addditional class
Program group
NavigableSetTest.java
NavigableSet
NavigatableSet1.java
NavigableSet
HashSet1.java
HashSet
HashSet2.java
HashMap1.java
HashMap
HashMap2.java
Vehicletest1.java
Vehicle.java
Vehicleregister.java
HashMap
TreeSet1.java
TreeSet
TreeSet2.java
TreeSet
TreeSet3.java
TreeSet
Booktest1
Book.java
Library.java
TreeMap
TreeMap2.java
TreeMap
TreeMapTest.java
TreeMAp
SetTest.java
Set.java
FrameGraphic.java
Planets1.java
vanderWaalstest.java
ArrayList
Vector
vanderWaalsData.java
vanderWaals.java
ArrayList
EX6.2 ) TreeMap2.java is given list of student identification numbers and student names as two String
arrays and student with the id # 05090000580 is listed. Check out exercise HashMap1.java, and
HashMap2.java similar to TreeMap2.java list name of student with the id # 05090000580 by using
HasMap class.
EX6.3) Use the list of student names in exercise 1 (given you in TreeMap2) and load it into Vector
class, list the names, then delete name
"ARTUN
TÜTEN
"
from the Vector and list the remaining again
WEEK 6 HOMEWORK ASSIGNMENTS
HW 6.1 One of the program investigated last semester to understand array structure usage was the hotel
program. This program is using the array structure double guess[]; to store the number of guess information in each
room, but as room numbers it is using the array indices 0,1,2,… Could you change to program into
HashMap<Integer,Integer> structure so that the first number will store the actual room numbers of the hotel room and the
second number will be number of guess in that room
public class hotel
{
String hotel_name;
int number_of_rooms;
double guess[];
public hotel(String i_hotel_name,int i_number_of_rooms)
{ hotel_name=i_hotel_name;
number_of_rooms=i_number_of_rooms;
guess=new double[number_of_rooms];
}
public hotel(String i_hotel_name,double i_guess[])
{ hotel_name=i_hotel_name;
number_of_rooms=i_guess.length;
guess=new double[number_of_rooms];
for(int room_number=0;room_number<number_of_rooms;room_number++)
{guess[room_number]=i_guess[room_number];}
}
public void room_registration(int room_number,int number_of_customers)
{ guess[room_number]=number_of_customers;}
public void room_registration(double i_guess[])
{
int n=i_guess.length;
for(int room_number=0;room_number<n;room_number++)
{guess[room_number]=i_guess[room_number];}
}
public int number_of_guess()
{
int nog=0;
for(int room_number=0;room_number<number_of_rooms;room_number++)
{nog+=guess[room_number];}
return nog;
}
public String toString()
{
String s="Hotel name : "+hotel_name+"\n";
s+="Total number of guess : "+number_of_guess()+"\n";
for(int room_number=0;room_number<number_of_rooms;room_number++)
{s+="room number = "+room_number+" number of guess = "+guess[room_number]+"\n";}
return s;
}
public String name(){return hotel_name;}
}
import javax.swing.*;
class hoteltest1
{
public static void main(String args[])
{
hotel h1=new hotel("long view",5);
h1.room_registration(0,3);
h1.room_registration(1,2);
double a[]={1,3,4,5,1,2,3,6};
hotel h2=new hotel("nice beach",a);
hotel h3=new hotel("blue point",10);
double b[]={2,1,2,3,1,2,3};
h3.room_registration(b);
h3.room_registration(8,3);
String s=h1.toString()+"\n "+
h2.toString()+"\n "+
h3.toString()+"\n ";
JOptionPane.showMessageDialog(null,s,
"Hotel registry list",JOptionPane.PLAIN_MESSAGE);
System.exit(0);}
}
HW6.2) NavigableSet1.java program is given. In this set student list strictly smaller than
"BERNA
NASUF
"
is required. Add the needed command to the programming code to achive this.
import java.util.*;
import javax.swing.*;
import java.util.concurrent.*;
public class NavigatableSet1
{
public static void main(String args[])
{
String student_name[]={"MUSA
GÜNGÖRÜRLER ",
"BERNA
NASUF
",
"BERK
SUROYI
",
"Başak
ŞİLEN
",
"Cem
DORU
",
"Veysel
AKSOY
",
"NAİL
YAKUPOĞLU
",
"TUNÇ
YAZICI
",
"YAVUZ
DURSUN
",
"ARDA
İNÇELİ
",
"BENGÜL
ERKEK
",
"MEHMET ARDA
ÖZDEN",
"ONUR
ÖCAL
",
"RİYAD GÖRKEM
KURAN",
"MUSTAFA SEMİH
DOĞAN",
"AYBÜKE
ORTAÇ
",
"ABDURRAHMAN
HASTUÇ",
"ERDAL
ÖREN
",
"OKAN
ALAK
",
"SELÇUK
YILDIRIM
",
"SEYFETTİN
CENGİZ ",
"HAKAN
KALKAN
",
"BURAK
TEMİZ
",
"İLKER OKAN
YILMAZ ",
"UTKU
TUTAR
",
"ŞENER
AKSU
",
"AYDIN
ELBİRLİK
",
"HARUN
NARİN
",
"MEHMET
TOZLU
",
"BAKHROM
ZHUMAEV
",
"MERT
BÜYÜKKÖPRÜ ",
"İBRAHİM
USLUER ",
"SERAY
ŞEN
",
"YUNUS
"HAYDAR MURAT
"FARUK
"MURAT
"ERDİ
"YİĞİT ŞİAR
"HAKAN ÖNDER
"FARUK
"EMRE
"İSMET
"FATİH
"TOLGA
"TUĞBA
"ÇAĞRI ALİM SEYİT
"MÜMİN ATAKAN
"NİHAT
"EMRE
"ERDEM
"GÖKSEL
"SERCAN
"AHMET HİLMİ
"ORHUN ESAT
"FIRAT
"MERTCAN
"ARDA
"KAZİM
"SEFA
"ENDER
"ANIL
"TANJU
"ÖMER KEMAL
"ONUR
"ONUR
"MURAT CAN
"ŞEREF
"MERVE
"OYTUN OZAN
"EZGİ
"HATİCE EBRU
"SERHAT
"NEDİM
"OĞULCAN
"EMRE
"SERKAN
"ARDA
"ÖMER
"KORAY
"MUSTAFA ORHUN
"AYSUN
"ÖZGÜN
"İSMAİL CEM
"İREM
"BERK
"FURKAN
"DOĞUKAN
"CAN BERKER
"YİĞİT
"HASAN
IŞILDAR
",
SÜTŞURUP",
TUNA
",
URAL
",
GÖKALP
",
BAŞOL ",
ÇOLAK",
YILMAZ
",
ŞİMŞEK
",
ÖZCAN
",
TOPLAR
",
ALTINOLUK
",
BİLGİLİ
",
METİN",
ÖZTAŞ ",
KURT
",
GÜRSOY
",
SARICA
",
KÖSE
",
KAYNAK
PAKSOY",
ŞAFAK ",
TOKUL
",
MUT
",
TUNA
",
ORAN
",
EKER
",
YILDIRIM
",
YILDIZ
",
AKYÜZ
",
ÇELİK ",
YILMAZTÜRK ",
ŞEN
",
TEKİN",
KERECİ ",
KARABEY
",
KORKMAZ",
AKÇA
",
EVREN",
SAYDAM
PEHLİVAN
",
IŞITMAN
",
ÖZDOĞAN
",
ORUN
",
ÇAKIRCI
",
RÜZGAR
",
ARICI
",
IRVANA",
GÜVEN
",
KÖKSAL
",
YÜRÜŞEN
",
AYDIN
",
KARAKAŞ
",
KADAKAL
DENİZ ",
ÖZDEM ",
BÜYÜKBOYACI ",
OĞUROL
",
",
",
",
"FATİH
"OLGAY
"AHMET
"ERKAN
"MIRAM
"ARTUN
"ERİNÇ
"SİNAN
"İSMAİL
"NAİM
"ÖZGÜR
"SELÇUK
"NEBİ
KAYA
ÇAKIR
",
",
PEHLİVANOĞULLARI",
ARSLAN
",
BAISSEYEV
",
TÜTEN
",
BAYTEKİN
",
ÇİFTÇİ
",
YILMAZ
",
ERGİN
",
OCAK
",
ŞEKERCİ
SUDAY
"
",
};
NavigableSet <String>nSet = new ConcurrentSkipListSet<String>();
for(int i=0;i<student_name.length;i++)
{nSet.add(student_name[i]);}
}
}
HW6.3) Intersection and Union of two sets are defined in class setA listed in setTest.java. Add
another method difference to get the difference of intersection and union as another method in setA,
test the method.
Download