Traditional Culture Encyclopedia - Hotel accommodation - How to do the data statistics module of hotel management system? Great god asks for advice (java)

How to do the data statistics module of hotel management system? Great god asks for advice (java)

Find a simple one:

Import? Java . util . scanner;

Public? Class? a 1{

Public? Static electricity Invalid? main(String[]? args){

Scanner? s? =? New? Scanner (system. in); //Accept the customer's keyboard input. At the command line, enter is over.

System.out.println(? Hotel Management System? );

Hotel? h? =? New? Hotel ();

System.out.println(? h? );

h . print();

What time? (Correct) {

System.out.println(? Please enter the room number. );

//Declare a variable to accept data input from the console.

String? No? =? s . next();

//Book a room

Order (None);

h . print();

}

}

}

Class? Room {

//room number

Private? String? No;

//Room type

Private? String? Type;

//Hello?

Private? Bull? isUse

Public? Room(){// Default call

super();

}

Public? Room (string? No, string? Type, Boolean? isUse){

super();

Don't you have this? =? No;

This type? =? Type;

This. Can I use it? =? isUse

}

Public? String? getNo(){

Return? No;

}

Public? Invalid? SetNo (string? No) {

Don't you have this? =? No;

}

Public? String? getType(){

Return? Type;

}

Public? Invalid? SetType (string? Type) {

This type? =? Type;

}

Public? Bull? isUse(){

Return? isUse

}

Public? Invalid? SetUse (Boolean? isUse){

This. Can I use it? =? isUse

}

Public? String? toString(){? //Declare the output result format

Return? "["? +? No? +? ","? +? Type? +? ","? +? (isUse? "occupied": "idle"? +? "]";

}

}

Class? Hotel {

Room? Room [] [];

Public? Hotel () {

Room? =? New? Room [5] [4]; //The hotel has five floors with four rooms on each floor.

for(int? I = 0; ? Me? & lt? Room. Length; ? ++i){// The external for loop is the loop layer, and the memory loop is the room that loops each layer.

for(int? j = 0; ? j? & lt? Room [i] Length; ? ++j){

What if? (me? ==? 0? ||? Me? ==? 1)? {

//Add an empty string after its automatic data type conversion, so that the previous number will automatically become a numeric string;

Room [i][j]? =? New? Room ((I+1) *100+j+1? +""? ,? "standard room", false);

}

What if? (me? ==? 2? ||? Me? ==? 3)? {

Room [i][j]? =? New? Room ((I+1) *100+j+1? +""? ,? "Double room", false); ?

}

What if? (me? ==? 4)? {

Room [i][j]? =? New? Room ((I+1) *100+j+1? +""? ,? "Deluxe room", fake); ?

}

}

}

}

//Print the room list for external use.

Public? Invalid? print(){

for(int? I = 0; ? Me? & lt? Room. Length; ? ++i){

for(int? j = 0; ? j? & lt? Room [i] Length; ? ++j){

System.out.print(? Room [i][j]? +? "?" ? );

}

//newline

System.out.println(? );

}

}

//Provide the way for the hotel to make external reservations.

Public? Invalid? Order (string? No) {

for(int? I = 0; ? Me? & lt? Room. Length; ? ++i){

for(int? j = 0; ? j? & lt? Room [i] Length; ? ++j){

What if? (conference room [i][j]. getNo()。 Equal to (no))? {

//Encapsulates the member data of the object and accesses it through the member method.

// 1? Access mode of member variable room [i][j]. No;

//2? How to access member methods

Room [i][j] SetUse (true);

Return;

}

}

}

}

} use the database.