I have a really tough project that is related to array list and files.
This project requires you to work with the arrayList data structure and text files. I will post an
ArrayListTemperatureAndBottleDemo class below that will guide you for this project. This program demonstrates the ArrayList add() method that will add an object to the
ArrayList, and the clear() method that will remove all the objects of an ArrayList. Also demonstrated is the for-each-loop. This loop
is related to the for loop and allows you to work through a data structure like and ArrayList and examine each element in that data
structure. Also, there is a method that demonstrates reading a series of integer numbers entered on a line. In this project you are to
model a group of art museums that wish to create exhibitions drawing from the paintings in their collections. The possible exhibitions
could be 1) all the paintings from one time period, or 2) all the paintings from a given country, or 3) all the paintings of a certain
painter, or 4) all the paintings of a certain genre such as Renaissance or Classical, or 5) all the paintings using a certain medium such
as Oil or Watercolor, or 6) all the paintings in a certain size range. For each exhibition the output will be a list of paintings satisfying
the requested category. Each museum has a list of paintings that are in a text file. This text file contains the necessary information
for each painting with the number of paintings for that museum as the first line of the text file. The program should allow the user to
continue creating exhibitions for as long as he wishes. I will supply the text files for each museum and output for whole project below.
- The array list temperature and bottle demo that will help guide you
import java.util.ArrayList;
import java.util.Scanner;
public class ArrayListTemperatureAndBottleDemo
{
public static void main(String[] args)
{
ArrayList<Temperature> tempArray = new ArrayList<Temperature>();
ArrayList<Bottle> bottleArray = new ArrayList<Bottle>();
Bottle b = new Bottle(3);//*** Bottle b is initialized with 3
tempArray.add(new Temperature(100,'C'));//*** ArrayList tempArray grows as needed
tempArray.add(new Temperature(100,'F'));
tempArray.add(new Temperature(400,'K'));
tempArray.add(new Temperature(200,'F'));
bottleArray.add(new Bottle(2));//*** ArrayList bottleArray grows as needed
bottleArray.add(b);
String temperatures = "";
for(Temperature temperature: tempArray)//*** for each loop goes through
{//*** ArrayList tempArray one at a time.
temperatures = temperatures + temperature.toString() + "n";//*** a String is created
}//*** using the toString() method of the Temperature class
System.out.println("first arrayn" + temperatures);//*** the String is printed
tempArray.clear();//*** the ArrayList tempArray is emptied
//*** method practice() is called returning an array assigned to tempArray
tempArray = practice(bottleArray);
temperatures = "";
for(Temperature temperature: tempArray)//*** for each loop again goes through
{//*** ArrayList tempArray one at a time.
temperatures = temperatures + temperature.toString() + "n";//*** a String is created
//*** using the toString() method of the Temperature class
}
System.out.println("second arrayn" + temperatures);//*** the String is printed
readString();//*** creating a Scanner that scans a String
}
private static ArrayList<Temperature> practice(ArrayList<Bottle> bottleArray)
{//*** ArrayList tempArray is created and will be returned
ArrayList<Temperature> tempArray = new ArrayList<Temperature>();
int degree;
Temperature f ;
for(Bottle bottle: bottleArray)//*** work through bottleArray
{
degree = bottle.getNumUnits();
f = new Temperature(degree, 'F');//*** MUST create Temperature with new
tempArray.add(f);//*** ArrayList grows as needed.
}
return tempArray;
}
private static void readString()
{
String example ="1 5 14 9";
Scanner scanLine = new Scanner(example);
while(scanLine.hasNextInt())
{
int choice = scanLine.nextInt();
System.out.println("choice is " + choice);
}
}
}
- The corcoan txt file
19
1
Angelico
The Coronation of the Virgin
1622
6.6
Renaissance
Oil
Italy
2
Ghirlandajo
Portrait of an Old Man
1590
3.5
Renaissance
Oil
Italy
3
Botticelli
The Virgin and Child
1603
2.4
Renaissance
Oil
Italy
4
Botticelli
Venus and the Three Graces
1579
2.4
Renaissance
Oil
Italy
5
Corot
Woman with a Pearl
1867
3.2
Renaissance
Oil
France
6
Leonardo Da Vinci
Study of draperies
1502
.5
Renaissance
Drawing
Italy
7
Leonardo Da Vinci
Mona Lisa
1500
2.4
Renaissance
Oil
Italy
8
Manet
The Picnic
1879
5.4
Impressionistic
Oil
France
9
Giorg
Open Air Concert
1930
4.3
Modern
Oil
Italy
10
Tintoretto
Paradise
1600
2.5
Renaissance
Drawing
Italy
11
La Tour
Adoration of the Shepherds
1679
1.3
Baroque
Oil
France
12
Ribera
The Clubfoot
1702
.5
Renaissance
Oil
Spain
13
Zurab
Funeral of Saint Bonaventurea
1965
2.4
Modern
Oil
Spain
14
Goya
Lady with a Fan
1795
2.4
Classical
Oil
Spain
15
Goya
Portrait of Guillemardet
1796
2.1
Classical
Oil
Spain
16
Goya
Portrait of the Marchioness of Solana
1793
2.8
Classical
Oil
Spain
17
Rubens
The Virgin of the Innocents
1803
3.3
Classical
Oil
Belgium
18
Memling
Portrait of an Old Woman
1480
1.3
Renaissance
Oil
Belgium
19
Metsis
The Moneylender and His Wife
1925
2.1
Modern
Oil
Belgium
- The whole museam code outline that must be used for this project
//import java.io.PrintWriter;
import java.util.Scanner;
public class CreateExhibition
{
public static void main(String[] args)
{
Curator exhibition = new Curator();
System.out.println("exhibition?");
while("yes")
{
String theExhibitionList = exhibition.paintingsChosen();
System.out.println(theExhibitionList);
System.out.println("a new exhibition?");
}
}
}
import java.util.ArrayList;
public class Curator
{
Declare Museums
Museum nationalGallery = null
String theExhibitionList
private ArrayList<Museum> museumsUsed = new ArrayList<Museum>();
private ArrayList<Painting> paintingsFromOneMuseumArray = new
private ArrayList<Painting> exhibitionPaintingsArray = new
public Curator()
{
Give museums memory
nationalGallery = new Museum("National Gallery",
"nationalGallery.txt")
}
public String paintingsChosen()
{
getMuseumsForTheExhibition();
topicSelection = selectTopic();
String paintingList = null;
switch (topicSelection)
{
case 1:// painter
String painter = getPainter();
paintingList = painter(painter, museumsUsed);
break;
}// switch
return theExhibitionList + paintingList;
}
private void getMuseumsForTheExhibition()
{
museumsUsed = new ArrayList<Museum>();
display museum choices
read choices
fill museumsUsed
}
private int selectTopic()
{ }
private String getPainter()
{ }
private String painter(String paintersName, ArrayList<Museum> museumArray)
{
exhibitionPaintingArray.clear();
for(Museum museum: museumArray)
{//*** ask each museum to give a list that satisfies the requested painter.
paintingsFromOneMuseumArray.clear();
//*** then from each museum put them in an ArrayList
paintingsFromOneMuseumArray= museum.painter(painterName);
//*** Add them to exhibitionPaintingsArray.
For(Painting p: paintingsFromOneMuseumArray)
exhibigtionPaintingArray.add();
}//for
}
}
private String createPaintingListFromExhibitionPaintingArray(String paintingListSoFar)
{ }
}
import java.util.ArrayList;
public class Museum
{
private String museum;
private ArrayList<Painting> paintingArray = new ArrayList<Painting>();
public Museum(String museumName, String paintingFile)
{
Scanner scanMuseumFile = TextFileIO.createTextRead(paintingFile);
readFile(scanMuseumFile);
scanMuseumFile.close();
}
public void readFile(Scanner read)
{ }
//*** The Museum class can return an ArrayList of paintings ***
//*** given the choice from the client.
public ArrayList<Painting> genre(String genre)
{ }
public ArrayList<Painting> country(String desiredCountry)
{ }
public ArrayList<Painting> datePainted(int start, int end)
{ }
public ArrayList<Painting> painter(String paintersName)
{ }
public ArrayList<Painting> size(double start, double end)
{ }
public ArrayList<Painting> medium(String desiredMedium)
{ }
public String toString()
{ }
}
public class Painting
{
public void readPainting(Scanner read)
{ }
Get and set methods.
public String toString()
{ }
}
import java.util.ArrayList;
import java.util.Scanner;
public class ArrayListDemo
{
public static void main(String[] args)
{
ArrayList<Fraction> fracArray = new ArrayList<Fraction>();
ArrayList<Bottle> bottleArray = new ArrayList<Bottle>();
Bottle b = new Bottle(3);
fracArray.add(new Fraction(1,2));
fracArray.add(new Fraction(1,3));
fracArray.add(new Fraction(1,5));
fracArray.add(new Fraction(1,6));
bottleArray.add(new Bottle(2));
bottleArray.add(b);
String fractions = "";
for(Fraction fraction: fracArray)
{
fractions = fractions + fraction.toString() + "n";
}
System.out.println("first arrayn" + fractions);
fracArray.clear();
fracArray = practice(bottleArray);
fractions = "";
for(Fraction fraction: fracArray)
{
fractions = fractions + fraction.toString() + "n";
}
System.out.println("second arrayn" + fractions);
readString();
}
private static ArrayList<Fraction> practice(ArrayList<Bottle> bottleArray)
{
ArrayList<Fraction> fracArray = new ArrayList<Fraction>();
int num, den;
Fraction f;
for(Bottle bottle: bottleArray)
{
num = bottle.getNumUnits();
den = num + 2;
f = new Fraction(num, den);
fracArray.add(f);
}
return fracArray;
}
private static void readString()
{
String example ="1 5 14 9";
Scanner scanLine = new Scanner(example);
while(scanLine.hasNextInt())
{
int choice = scanLine.nextInt();
System.out.println("choice is " + choice);
}
}
}
- National gallery txt
20
1
Giotto
Saint Francis of Assisi
1590
2.9
Renaissance
Tempera
Italy
2
Angelico
Martyrdom of Saint Cosmus
1602
4.6
Renaissance
Oil
Italy
3
Pisanello
Study of Ducks
1640
1.3
Renaissance
Drawing
Italy
4
Pisanello
Portrait of a Lady
1598
0.7
Renaissance
Oil
Italy
5
Tura
Pieta
1480
6.7
Renaissance
Oil
Italy
6
Bellini
Christ Blessing after the Resurrection
1501
2.1
Renaissance
Oil
Italy
7
Degas
A Ballet Dancer in Position
1872
.7
Impressionistic
Drawing
France
8
Correggio
Saint James the Minor
1530
1
Renaissance
Drawing
Italy
9
Correggio
The Sleep of Antiope
1502
3.2
Renaissance
Oil
Italy
10
Van Dyck
Lady Venetia Digaby
1650
4
Classical
Oil
Belgium
11
Veronese
The Marriage at Cana
1570
12.5
Renaissance
Oil
Italy
12
El Greco
Portrait of Covarrubbias
1559
.5
Renaissance
Oil
Spain
13
El Greco
Christ of the Cross
1560
5.4
Renaissance
Oil
Spain
14
Renoir
Portrait of Madame Charpentier
1890
1.78
Impressionistic
Oil
France
15
Velasquez
Portrait of Queen Marianna
1700
2.1
Renaissance
Oil
Spain
16
Van Eyck
The Virgin with the Chancellor Rolin
1420
2.3
Renaissance
Oil
Belgium
17
Van Der Weyden
The Annunciation
1439
3.1
Renaissance
Oil
Belgium
18
David
Madame Recamier
1790
2.5
Classical
Oil
French
19
El Grenara
Portrait of a Lady
1959
.5
Modern
Oil
Spain
20
Van Der Hoveven
The Annunciation
1939
3.1
Modern
Oil
Belgium
- How the output should look like for this project
This program creates art exhibitions.
Would you like to create new exhibition?
Enter yes or no.
yes
For this exhibition, from which Museums would
you like the art work be drawn?
Please enter their numbers on one line.
1) National Gallery
2) Philips Collection
3) Corcoran
4) Portrait Gallery
1 2 3 4
Now that you have chosen the museums,
please choose an exhibition topic
and enter its number.
1) Painter
2) Year painted
3) Size
4) Medium
5) Country
6) Genre
5
Please enter a Country
France
The exhibition is drawn from these museums:
National Gallery
Philips Collection
Corcoran
Portrait Gallery
The paintings from France are:
1)Degas 1872 A Ballet Dancer in Position
Impressionistic Drawing France 0.7
2)Renoir 1890 Portrait of Madame Charpentier
Impressionistic Oil France 1.78
3)Martini 1602 The carrying of the Cross
Renaissance Oil France 5.3
4)Corot 1867 Woman with a Pearl
Renaissance Oil France 3.2
5)Manet 1879 The Picnic
Impressionistic Oil France 5.4
6)La Tour 1679 Adoration of the Shepherds
Baroque Oil France 1.3
7)Degas 1874 Dancer Adjusting Her Sipper
Impressionistic Drawing France 1.0
8)Degas 1874 Dancer Resting
Impressionistic Drawing France 1.5
9)Degas 1874 Dancing Master
Impressionistic Drawing France 0.9
10)Degas 1875 The Dancer Jules Perrot
Impressionistic Oil France 1.3
11)Degas 1873 Dancer Adjusting Her Costume
Impressionistic Drawing France 1.2
12)Van Gogh 1889 Self-portrait
Impressionistic Oil France 0.9
13)Gauguin 1890 Self-portrait
Impressionistic Oil France 2.1
Would you like to create new exhibition?
Enter yes or no.
yes
For this exhibition, from which Museums would
you like the art work be drawn?
Please enter their numbers on one line.
1) National Gallery
2) Philips Collection
3) Corcoran
4) Portrait Gallery
1 2
Now that you have chosen the museums,
please choose an exhibition topic
and enter its number.
1) Painter
2) Year painted
3) Size
4) Medium
5) Country
6) Genre
2
Please enter the range of years the
paintings were painted. Please enter
the years on one line. The first year must
be smaller than the second.
1700 1800
The exhibition is drawn from these museums:
National Gallery
Philips Collection
The paintings from 1700 to 1800 are:
1)Velasquez 1700 Portrait of Queen Marianna
Renaissance Oil Spain 2.1
2)David 1790 Madame Recamier
Classical Oil French 2.5
3)Uccello 1700 Rout of San Romano
Baroque Oil German 5.6
4)Magnasco 1725 Landscape
Baroque Oil Italy 4.5
5)Tiepolo 1790 the Minuet
Baroque Oil Italy 3.5
6)Velasquez 1730 Portrait of the Infant Margaret
Classical Oil Spain 2.4
Would you like to create new exhibition?
Enter yes or no.
yes
For this exhibition, from which Museums would
you like the art work be drawn?
Please enter their numbers on one line.
1) National Gallery
2) Philips Collection
3) Corcoran
4) Portrait Gallery
1 2 3
Now that you have chosen the museums,
please choose an exhibition topic
and enter its number.
1) Painter
2) Year painted
3) Size
4) Medium
5) Country
6) Genre
3
Please enter the size range of the
paintings on one line. The first size must
be smaller than the second.
2 4
The exhibition is drawn from these museums:
National Gallery
Philips Collection
Corcoran
The paintings in size from 2.0 to 4.0 meters are:
1)Giotto 1590 Saint Francis of Assisi
Renaissance Tempera Italy 2.9
2)Bellini 1501 Christ Blessing after the Resurrection
Renaissance Oil Italy 2.1
3)Correggio 1502 The Sleep of Antiope
Renaissance Oil Italy 3.2
4)Van Dyck 1650 Lady Venetia Digaby
Classical Oil Belgium 4.0
5)Velasquez 1700 Portrait of Queen Marianna
Renaissance Oil Spain 2.1
6)Van Eyck 1420 The Virgin with the Chancellor Rolin
Renaissance Oil Belgium 2.3
7)Van Der Weyden 1439 The Annunciation
Renaissance Oil Belgium 3.1
8)David 1790 Madame Recamier
Classical Oil French 2.5
9)Van Der Hoveven 1939 The Annunciation
Modern Oil Belgium 3.1
10)Cimabue 1560 The Virgin with the Angels
Renaissance Oil Italy 3.5
11)Carpaccio 1490 Saint Stephen Preaching at Jerusalem
Renaissance Oil Italy 3.4
12)Titcomian 1945 Portrait of a Young Woman
Modern Oil Italy 3.2
13)Tiepolo 1790 the Minuet
Baroque Oil Italy 3.5
14)Velasquez 1730 Portrait of the Infant Margaret
Classical Oil Spain 2.4
15)Jan Fyt 1804 Games and Hutting Objects
Classical Oil Belgium 2.1
16)Ghirlandajo 1590 Portrait of an Old Man
Renaissance Oil Italy 3.5
17)Botticelli 1603 The Virgin and Child
Renaissance Oil Italy 2.4
18)Botticelli 1579 Venus and the Three Graces
Renaissance Oil Italy 2.4
19)Corot 1867 Woman with a Pearl
Renaissance Oil France 3.2
20)Leonardo Da Vinci 1500 Mona Lisa
Renaissance Oil Italy 2.4
21)Tintoretto 1600 Paradise
Renaissance Drawing Italy 2.5
22)Zurab 1965 Funeral of Saint Bonaventurea
Modern Oil Spain 2.4
23)Goya 1795 Lady with a Fan
Classical Oil Spain 2.4
24)Goya 1796 Portrait of Guillemardet
Classical Oil Spain 2.1
25)Goya 1793 Portrait of the Marchioness of Solana
Classical Oil Spain 2.8
26)Rubens 1803 The Virgin of the Innocents
Classical Oil Belgium 3.3
27)Metsis 1925 The Moneylender and His Wife
Modern Oil Belgium 2.1
Would you like to create new exhibition?
Enter yes or no.
yes
For this exhibition, from which Museums would
you like the art work be drawn?
Please enter their numbers on one line.
1) National Gallery
2) Philips Collection
3) Corcoran
4) Portrait Gallery
1 2
Now that you have chosen the museums,
please choose an exhibition topic
and enter its number.
1) Painter
2) Year painted
3) Size
4) Medium
5) Country
6) Genre
6
Please choose the genre
and enter its number.
1) Renaissance
2) Baroque
3) Classical
4) Impressionistic
5) Modern
4
The exhibition is drawn from these museums:
National Gallery
Philips Collection
The paintings from the Impressionistic period are:
1)Degas 1872 A Ballet Dancer in Position
Impressionistic Drawing France 0.7
2)Renoir 1890 Portrait of Madame Charpentier
Impressionistic Oil France 1.78
Would you like to create new exhibition?
Enter yes or no.
yes
For this exhibition, from which Museums would
you like the art work be drawn?
Please enter their numbers on one line.
1) National Gallery
2) Philips Collection
3) Corcoran
4) Portrait Gallery
1 2 3 4
Now that you have chosen the museums,
please choose an exhibition topic
and enter its number.
1) Painter
2) Year painted
3) Size
4) Medium
5) Country
6) Genre
4
Please choose the medium
and enter its number.
1) Oil
2) Water Color
3) Drawing
4) Tempera
2
The exhibition is drawn from these museums:
National Gallery
Philips Collection
Corcoran
Portrait Gallery
Water Color is the medium for this list of paintings.
Would you like to create new exhibition?
Enter yes or no.
yes
For this exhibition, from which Museums would
you like the art work be drawn?
Please enter their numbers on one line.
1) National Gallery
2) Philips Collection
3) Corcoran
4) Portrait Gallery
1 2 3 4
Now that you have chosen the museums,
please choose an exhibition topic
and enter its number.
1) Painter
2) Year painted
3) Size
4) Medium
5) Country
6) Genre
4
Please choose the medium
and enter its number.
1) Oil
2) Water Color
3) Drawing
4) Tempera
3
The exhibition is drawn from these museums:
National Gallery
Philips Collection
Corcoran
Portrait Gallery
Drawing is the medium for this list of paintings.
1)Pisanello 1640 Study of Ducks
Renaissance Drawing Italy 1.3
2)Degas 1872 A Ballet Dancer in Position
Impressionistic Drawing France 0.7
3)Correggio 1530 Saint James the Minor
Renaissance Drawing Italy 1.0
4)Raphael 1520 Psyche and Venus
Renaissance Drawing Italy 0.2
5)Leonardo Da Vinci 1502 Study of draperies
Renaissance Drawing Italy 0.5
6)Tintoretto 1600 Paradise
Renaissance Drawing Italy 2.5
7)Degas 1874 Dancer Adjusting Her Sipper
Impressionistic Drawing France 1.0
8)Degas 1874 Dancer Resting
Impressionistic Drawing France 1.5
9)Degas 1874 Dancing Master
Impressionistic Drawing France 0.9
10)Degas 1873 Dancer Adjusting Her Costume
Impressionistic Drawing France 1.2
Would you like to create new exhibition?
Enter yes or no.
no
Thank you for creating exhibitions of paintings.
- Philips collection txt file
18
1
Cimabue
The Virgin with the Angels
1560
3.5
Renaissance
Oil
Italy
2
Martini
The carrying of the Cross
1602
5.3
Renaissance
Oil
France
3
Baldovinetti
Virgin and Child
1593
4.6
Renaissance
Oil
Italy
4
Uccello
Rout of San Romano
1700
5.6
Baroque
Oil
German
5
Carpaccio
Saint Stephen Preaching at Jerusalem
1490
3.4
Renaissance
Oil
Italy
6
Mantegna
The Calvary
1500
5.7
Renaissance
Oil
Italy
7
Leonardo Da Vinci
The Virgin, the Child
1480
4.2
Renaissance
Oil
Italy
8
Raphael
Psyche and Venus
1520
0.2
Renaissance
Drawing
Italy
9
Raphael
La Belle Jardiniere
1510
1.3
Renaissance
Oil
Italy
10
Titian
The Entombment
1550
6.7
Renaissance
Oil
Italy
11
Titcomian
Portrait of a Young Woman
1945
3.2
Modern
Oil
Italy
12
Magnasco
Landscape
1725
4.5
Baroque
Oil
Italy
13
Tiepolo
the Minuet
1790
3.5
Baroque
Oil
Italy
14
Zurranian
Saint Apoline
1990
6.3
Modern
Oil
Spain
15
Velasquez
Portrait of the Infant Margaret
1730
2.4
Classical
Oil
Spain
16
Jan Fyt
Games and Hutting Objects
1804
2.1
Classical
Oil
Belgium
17
Brouwer
The Worker
1930
1.3
Modern
Oil
Belgium
18
Rembrandt
Self-portrait
1659
.8
Classical
Oil
Dutch
- portrait gallery txt
20
1
Memling
Portrait of an Old Woman
1480
1.3
Renaissance
Oil
Belgium
2
Metsys
The Moneylender and His Wife
1525
2.1
Renaissance
Oil
Belgium
3
Degas
Dancer Adjusting Her Sipper
1874
1.0
Impressionistic
Drawing
France
4
Degas
Dancer Resting
1874
1.5
Impressionistic
Drawing
France
5
Degas
Dancing Master
1874
.9
Impressionistic
Drawing
France
6
Degas
The Dancer Jules Perrot
1875
1.3
Impressionistic
Oil
France
7
Leonardo Da Vinci
The Virgin of the Rocks
1498
3.2
Renaissance
Oil
Italy
8
Degas
Dancer Adjusting Her Costume
1873
1.2
Impressionistic
Drawing
France
9
Bacciarelli
Stanislaus Augustus Poniatowski
1891
3.4
Classical
Oil
Italy
10
Titian
The Man with a Glove
1560
4.5
Classical
Oil
Italy
11
Rembrandt
Portrait of a Young Man
1650
2.4
Classical
Oil
Dutch
12
Rembrandt
Girl Leaning on a Stone Pedestal
1650
3.4
Classical
Oil
Dutch
13
Murillo
The Flower Girl
1676
.7
Classical
Oil
Spain
14
Tiepolo
Man with a Bird
1759
.6
Classical
Drawing
Italy
15
Gainsborough
Phillippe-Jacques
1755
.5
Classical
Oil
English
16
Lely
Portrait of a Boy as a Shepherd
1750
2.3
Classical
Oil
Britain
17
Van Gogh
Self-portrait
1889
.9
Impressionistic
Oil
France
18
Gauguin
Self-portrait
1890
2.1
Impressionistic
Oil
France
19
Leo Vincia
The Rocks
1998
3.2
Modern
Oil
Italy
20
Trobitian
The Glove
1960
4.5
Modern
Oil
Italy
Unlock full access to Course Hero
Explore over 16 million step-by-step answers from our library
Get answerOur verified expert tutors typically answer within 15-30 minutes.