Art Gallery

/* This program will generate information for specifc paintings at the Art Gallery for all the visitors Auther---- Tsotne Gvadzabia Date--- 13/10/16 */ import java.util.Scanner; //imports scanner class artgallery { public static void main (String[]p) { int roomnum = 0; // Room number variable roomnum=question(roomnum); if (roomnum==1) //if the roomnumber is 1 it will go to this method { infoprinter(); } else if(roomnum==2) //if the roomnumber is 2 it will go to this method { infoprinter2(); } else if(roomnum==3) //if the roomnumber is 3 it will go to this method { infoprinter3(); } else if(roomnum==4) //if the roomnumber is 4 it will go to this method { infoprinter4(); } else if(roomnum==5) //if the roomnumber is 5 it will go to this method { infoprinter5(); } else //Program stops after displaying an error messege { System.out.println("The room number you entered does not exist. Please only enter a number"); System.exit(0); } System.exit(0); } public static int question(int roomnum) //This is where the user gets asked what room they are in { Scanner scanner = new Scanner(System.in); System.out.println("Please enter the room number you are in"); roomnum = scanner.nextInt(); return roomnum; } public static void infoprinter() { paintings p1= new paintings(); //method for the first room p1=setDirection(p1,"The painting ahead of you"); p1=setArtist(p1,"Mary Cassatt"); p1=setTitle(p1,"Woman with a Pearl Necklace in a Loge"); p1=setYear(p1,1879); p1=setHeight(p1,"81.3cm"); p1=setWidth(p1,"59.7cm"); System.out.println(getDirection(p1) + " is by "+ getArtist(p1)+".It was painted in "+ getYear(p1)+" and is called "+getTitle(p1)+".It is "+ getHeight(p1) + " by "+getWidth(p1) +"."); } public static void infoprinter2() //method for the second room { paintings p2 = new paintings(); p2 = setDirection(p2,"The painting ahead of you"); p2 = setArtist(p2,"Rembrandt"); p2 = setTitle(p2,"Self-Portrait With Beret and Turned-Up Collar"); p2 = setYear(p2,1652); p2 = setHeight(p2,"84.5cm"); p2 = setWidth(p2,"66.8cm"); System.out.println(getDirection(p2) + " is by "+ getArtist(p2)+".It was painted in "+ getYear(p2)+" and is called "+getTitle(p2)+".It is "+ getHeight(p2) + " by "+getWidth(p2) +"."); } public static void infoprinter3() //method for the third room { paintings p3 = new paintings(); p3=setDirection(p3,"The painting on the left"); p3=setArtist(p3,"Olga Boznanska"); p3=setTitle(p3,"Girl with Chrysanthemums"); p3=setYear(p3,1894); p3=setHeight(p3,"88.5cm"); p3=setWidth(p3,"69.0cm"); System.out.println(getDirection(p3) + " is by "+ getArtist(p3)+".It was painted in "+ getYear(p3)+" and is called "+getTitle(p3)+".It is "+ getHeight(p3) + " by "+getWidth(p3) +"."); } public static void infoprinter4() // method for the 4th room { paintings p4 = new paintings(); p4=setDirection(p4,"The painting on your right"); p4=setArtist(p4,"Claude Monet"); p4=setTitle(p4,"Impression, Sunrise"); p4=setYear(p4,1872); p4=setHeight(p4,"81.3cm"); p4=setWidth(p4,"59.7cm"); System.out.println(getDirection(p4) + " is by "+ getArtist(p4)+".It was painted in "+ getYear(p4)+" and is called "+getTitle(p4)+".It is "+ getHeight(p4) + " by "+getWidth(p4) +"."); } public static void infoprinter5() //method for the 5th room { paintings p5 = new paintings(); p5=setDirection(p5,"The massive painting on the cieling"); p5=setArtist(p5,"Peter Paul Rubens"); p5=setTitle(p5,"The Judgement of Paris"); p5=setYear(p5,1639); p5=setHeight(p5,"199.0cm"); p5=setWidth(p5,"379.0cm"); System.out.println(getDirection(p5) + " is by "+ getArtist(p5)+".It was painted in "+ getYear(p5)+" and is called "+getTitle(p5)+".It is "+ getHeight(p5) + " by "+getWidth(p5) +"."); } //Setter and Getter methods for all the paintings are below public static String getDirection(paintings p) { return p.direction; } public static String getArtist(paintings p) { return p.artist; } public static String getTitle(paintings p) { return p.title; } public static int getYear(paintings p) { return p.year; } public static String getHeight(paintings p) { return p.height; } public static String getWidth(paintings p) { return p.width; } public static paintings setDirection(paintings p,String d) { p.direction=d; return p; } public static paintings setArtist(paintings p, String a) { p.artist = a; return p; } public static paintings setTitle(paintings p, String t) { p.title =t; return p; } public static paintings setYear(paintings p, int y) { p.year = y; return p; } public static paintings setHeight(paintings p, String h) { p.height = h; return p; } public static paintings setWidth(paintings p,String w) { p.width = w; return p; } } class paintings { String direction; String artist; String title; int year; String height; String width; }
A Program for an Art Gallery

The user inputs which room number they are in and the program generates information concerning the painting within that room.

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.