NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

PrintSeat.java

import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;


/*
* COPYRIGHT. HSBC HOLDINGS PLC 2014. ALL RIGHTS RESERVED.
*
* This software is only to be used for the purpose for which it has been
* provided. No part of it is to be reproduced, disassembled, transmitted,
* stored in a retrieval system nor translated in any human or computer
* language in any way or for any other purposes whatsoever without the prior
* written consent of HSBC Holdings plc.
*/

/**
* <p>
* <b> TODO : Insert description of the class's responsibility/role. </b>
* </p>
*/
public class PrintSeat {

public static void seating() throws FileNotFoundException {
String seatNo[] = new String[100];
Scanner in = new Scanner(new File("seat.txt"));
for (int i = 0; in.hasNext(); i++) {
seatNo[i] = in.next();
}

int temp = 0;
int temp2 = 0;
int rowseat = 0;

int seatstart = 1;
// print format

System.out
.print(" *********************************************SCREEN****************************************************");
System.out.println();

System.out
.println(" | |");

for (char i = 'A'; i <= 'K'; i++) {


// System.out.println();
if ((((int) i) % 2) != 0) {
rowseat = 20;
} else {
rowseat = 20;
}
if (rowseat == 19) {
System.out.print(" ");
}
System.out.print(i + " |");


if (seatNo[temp].charAt(1) != i) {
for (int k = 1; k <= rowseat; k++) {
if (k < 10) {
System.out.print(" [0" + k + "]");

} else {
System.out.print(" [" + k + "]");
}

}
}
while ((seatNo[temp] != null) && (seatNo[temp].charAt(1) == i)) {

if (seatNo[temp].charAt(2) == '0') {

for (int k = seatstart; k < ((int) seatNo[temp].charAt(3) - 48); k++) {

System.out.print(" [0" + k + "]");
seatstart = k + 1;


}

seatstart++;

System.out.print(" [--]");


} else if (seatNo[temp].charAt(2) == '1') {
for (int k = seatstart; k < ((int) seatNo[temp].charAt(3) - 48 + 10); k++) {

if (k < 10) {
System.out.print(" [0" + k + "]");

} else {
System.out.print(" [" + k + "]");
}
seatstart = k + 1;
}
System.out.print(" [--]");
seatstart++;


} else if (seatNo[temp].charAt(2) == '2') {
for (int k = seatstart; k < ((int) seatNo[temp].charAt(3) - 48 + 20); k++) {

if (k < 10) {
System.out.print(" [0" + k + "]");

} else {
System.out.print(" [" + k + "]");
}
seatstart = k + 1;
}
System.out.print(" [--]");
seatstart++;
}

if (seatNo[temp + 1] != null) {

temp2 = seatstart;
if (seatNo[temp + 1].charAt(1) != i) {
for (int k = 1; k <= rowseat - seatstart + 1; k++) {
if (temp2 < 10) {
System.out.print(" [0" + temp2 + "]");
} else {
System.out.print(" [" + temp2 + "]");
}
temp2++;
}
}
} else {
temp2 = seatstart;
for (int k = 1; k <= rowseat - seatstart + 1; k++) {

if (temp2 < 10) {
System.out.print(" [0" + temp2 + "]");
} else {
System.out.print(" [" + temp2 + "]");
}
temp2++;
}
}

temp++;

}

seatstart = 1;
System.out.println(" | " + i);
System.out
.println(" | |");
}
System.out
.println(" -------------------------------------------------------------------------------------------------------");

/**
* System.out.println(); System.out.print("\");
*
* for (int i = 1; i <= 9; i++) {
*
* System.out.print(" " + i); } for (int i = 10; i <= 20; i++) {
*
* System.out.print(" " + i); }
**/

}
}
===================================================================================
film.java

/*
* COPYRIGHT. HSBC HOLDINGS PLC 2014. ALL RIGHTS RESERVED.
*
* This software is only to be used for the purpose for which it has been
* provided. No part of it is to be reproduced, disassembled, transmitted,
* stored in a retrieval system nor translated in any human or computer
* language in any way or for any other purposes whatsoever without the prior
* written consent of HSBC Holdings plc.
*/

/**
* <p>
* <b> TODO : Insert description of the class's responsibility/role. </b>
* </p>
*/
public class film {
private String house;
private String time;
private String name;
private String beginTime;
private int duration;

public film(final String house2, final String timeslot, final String beginTime, final int duration, final String name1) {
this.house = house2;
this.time = timeslot;
this.beginTime = beginTime;
this.duration = duration;
this.name = name1;
}

public String getTime() {
return this.time;
}

public String getBeginTime() {
return this.beginTime;
}

public String getHouse() {
return this.house;
}

public String getName() {
return this.name;
}

public int getDuration() {
return this.duration;
}

public String toString() {
return ("house: " + this.house + " begin time: " + this.beginTime + " duration: " + this.duration + " mins " + "name:" + this.name);

}
}

===================================================================================
Main.java

import java.io.FileNotFoundException;
import java.io.UnsupportedEncodingException;

/*
* COPYRIGHT. HSBC HOLDINGS PLC 2014. ALL RIGHTS RESERVED.
*
* This software is only to be used for the purpose for which it has been
* provided. No part of it is to be reproduced, disassembled, transmitted,
* stored in a retrieval system nor translated in any human or computer
* language in any way or for any other purposes whatsoever without the prior
* written consent of HSBC Holdings plc.
*/

/**
* <p>
* <b> TODO : Insert description of the class's responsibility/role. </b>
* </p>
*/
public class Main {
public static void main(final String[] args) throws FileNotFoundException, UnsupportedEncodingException {
PrintSeat.seating();
FilmDeck a = FilmDeck.getInstance();
a.getFilmFromText();

a.addFilm("A", "3", 120, "Sherlock");
a.addFilm("A", "1", 80, "Shrek");
a.addFilm("A", "2", 90, "The Day After Tomorrow");
a.addFilm("B", "4", 180, "End");
a.addFilm("C", "1", 180, "Avatar");
a.getInfo();

}
}
===================================================================================
FilmDeck.java

import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Scanner;

/*
* COPYRIGHT. HSBC HOLDINGS PLC 2014. ALL RIGHTS RESERVED.
*
* This software is only to be used for the purpose for which it has been
* provided. No part of it is to be reproduced, disassembled, transmitted,
* stored in a retrieval system nor translated in any human or computer
* language in any way or for any other purposes whatsoever without the prior
* written consent of HSBC Holdings plc.
*/

/**
* <p>
* <b> TODO : Insert description of the class's responsibility/role. </b>
* </p>
*/
public class FilmDeck {


private static FilmDeck instance = new FilmDeck();
private ArrayList<film> filmList = new ArrayList<film>();
private String[] time = new String[4];


public static FilmDeck getInstance() {
return FilmDeck.instance;
}

public void getTime() throws FileNotFoundException {
Scanner in = new Scanner(new File("timeslot.txt"));
for (int i = 0; i < 4; i++) {
this.time[i] = in.next();
}
in.close();
}

public void getFilmFromText() throws FileNotFoundException {

this.filmList.clear();
Scanner inFile = new Scanner(new File("film.txt"));
String house, timeslot, beginTime;
String Name;
int duration;
while (inFile.hasNextLine()) {
house = inFile.next();
timeslot = inFile.next();
beginTime = inFile.next();
duration = inFile.nextInt();
Name = inFile.nextLine();
this.filmList.add(new film(house, timeslot, beginTime, duration, Name));
}
}

public void getInfo() {
System.out.println("Film Detail: ");
for (film f : this.filmList) {
System.out.println(f);
}
}

public void addFilm(final String house, final String time1, final int duration, final String Name)
throws FileNotFoundException, UnsupportedEncodingException {
getTime();
this.filmList.add(new film(house, time1, convertTime(time1, this.time), duration, Name));
PrintWriter writer = new PrintWriter("film.txt", "UTF-8");
for (film f : this.filmList) {
writer.println(f.getHouse() + " " + f.getTime() + " " + f.getBeginTime() + " " + f.getDuration() + " " + f.getName());
}
writer.close();

}


public String convertTime(final String o, final String[] time) {
if (o == "1") {
return time[0];
}
if (o == "2") {
return time[1];
}
if (o == "3") {
return time[2];
}
if (o == "4") {
return time[3];
} else {
return null;
}
}

}
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.