By GokiSoft.com|
20:38 01/07/2022|
Java Basic
[Source Code] Quản lý bể bơi bằng Java - Swimming Pool in Java - C2108L
Quản lý bể bơi bằng Java - Swimming Pool in Java
#TimeZone.java
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package bt1213;
import java.util.Scanner;
/**
*
* @author Diep.Tran
*/
public class TimeZone {
String startTime;
String endTime;
String timeNo;
float price;
public TimeZone() {
}
public void input() {
Scanner input = new Scanner(System.in);
System.out.println("Nhap gio bat dau: ");
startTime = input.nextLine();
System.out.println("Nhap gio ket thuc: ");
endTime = input.nextLine();
System.out.println("Nhap ma khung gio: ");
timeNo = input.nextLine();
System.out.println("Nhap gia tien: ");
price = Float.parseFloat(input.nextLine());
}
public void display() {
// System.out.println(toString());
System.out.println(this);
}
@Override
public String toString() {
return "TimeZone{" + "startTime=" + startTime + ", endTime=" + endTime + ", timeNo=" + timeNo + ", price=" + price + '}';
}
public String getStartTime() {
return startTime;
}
public void setStartTime(String startTime) {
this.startTime = startTime;
}
public String getEndTime() {
return endTime;
}
public void setEndTime(String endTime) {
this.endTime = endTime;
}
public String getTimeNo() {
return timeNo;
}
public void setTimeNo(String timeNo) {
this.timeNo = timeNo;
}
public float getPrice() {
return price;
}
public void setPrice(float price) {
this.price = price;
}
}
#Ticket.java
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package bt1213;
import java.util.Scanner;
/**
*
* @author Diep.Tran
*/
public class Ticket {
String no;
String fullname;
String address;
String registeredDate;
String expiredDate;
String avatar;
float price;
public Ticket() {
}
public void input() {
Scanner scan = new Scanner(System.in);
System.out.println("Nhap ma ve: ");
no = scan.nextLine();
System.out.println("Nhap ten: ");
fullname = scan.nextLine();
System.out.println("Nhap dia chi: ");
address = scan.nextLine();
System.out.println("Nhap ngay mua: ");
registeredDate = scan.nextLine();
System.out.println("Nhap ngay het han: ");
expiredDate = scan.nextLine();
System.out.println("Nhap gia: ");
price = Float.parseFloat(scan.nextLine());
}
public void display() {
System.out.println(toString());
}
@Override
public String toString() {
return "Ticket{" + "no=" + no + ", fullname=" + fullname + ", address=" + address + ", registeredDate=" + registeredDate + ", expiredDate=" + expiredDate + ", avatar=" + avatar + ", price=" + price + '}';
}
public String getNo() {
return no;
}
public void setNo(String no) {
this.no = no;
}
public String getFullname() {
return fullname;
}
public void setFullname(String fullname) {
this.fullname = fullname;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getRegisteredDate() {
return registeredDate;
}
public void setRegisteredDate(String registeredDate) {
this.registeredDate = registeredDate;
}
public String getExpiredDate() {
return expiredDate;
}
public void setExpiredDate(String expiredDate) {
this.expiredDate = expiredDate;
}
public String getAvatar() {
return avatar;
}
public void setAvatar(String avatar) {
this.avatar = avatar;
}
public float getPrice() {
return price;
}
public void setPrice(float price) {
this.price = price;
}
}
#SwimmingPool.java
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package bt1213;
import java.util.ArrayList;
/**
*
* @author Diep.Tran
*/
public class SwimmingPool {
String poolNo;
String address;
ArrayList<Ticket> tickets;
ArrayList<DailyTicket> dailyTickets;
ArrayList<TimeZone> timeZones;
ArrayList<Booking> bookings;
public SwimmingPool() {
tickets = new ArrayList<>();
dailyTickets = new ArrayList<>();
timeZones = new ArrayList<>();
bookings = new ArrayList<>();
}
public String getPoolNo() {
return poolNo;
}
public void setPoolNo(String poolNo) {
this.poolNo = poolNo;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public ArrayList<Ticket> getTickets() {
return tickets;
}
public void setTickets(ArrayList<Ticket> tickets) {
this.tickets = tickets;
}
public ArrayList<DailyTicket> getDailyTickets() {
return dailyTickets;
}
public void setDailyTickets(ArrayList<DailyTicket> dailyTickets) {
this.dailyTickets = dailyTickets;
}
public ArrayList<TimeZone> getTimeZones() {
return timeZones;
}
public void setTimeZones(ArrayList<TimeZone> timeZones) {
this.timeZones = timeZones;
}
public ArrayList<Booking> getBookings() {
return bookings;
}
public void setBookings(ArrayList<Booking> bookings) {
this.bookings = bookings;
}
}
#Main.java
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package bt1213;
/**
*
* @author Diep.Tran
*/
public class Main {
public static void main(String[] args) {
SwimmingPool swimmingPool = new SwimmingPool();
}
}
#DailyTicket.java
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package bt1213;
import java.util.Scanner;
/**
*
* @author Diep.Tran
*/
public class DailyTicket {
String no;
String buyDate;
String timeNo;
public DailyTicket() {
}
public void input() {
Scanner input = new Scanner(System.in);
System.out.println("Nhap ma ve: ");
no = input.nextLine();
System.out.println("Nhap ngay mua: ");
buyDate = input.nextLine();
System.out.println("Nhap khung gio: ");
timeNo = input.nextLine();
}
public void display() {
// System.out.println(toString());
System.out.println(this);
}
@Override
public String toString() {
return "DailyTicket{" + "no=" + no + ", buyDate=" + buyDate + ", timeNo=" + timeNo + '}';
}
public String getNo() {
return no;
}
public void setNo(String no) {
this.no = no;
}
public String getBuyDate() {
return buyDate;
}
public void setBuyDate(String buyDate) {
this.buyDate = buyDate;
}
public String getTimeNo() {
return timeNo;
}
public void setTimeNo(String timeNo) {
this.timeNo = timeNo;
}
}
#Booking.java
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package bt1213;
import java.util.Scanner;
/**
*
* @author Diep.Tran
*/
public class Booking {
String bookingNo;
String timeNo;
String entireTime;
public Booking() {
}
public void input() {
Scanner scan = new Scanner(System.in);
System.out.println("Nhap ma dat ve: ");
bookingNo = scan.nextLine();
System.out.println("Nhap ma khung gio: ");
timeNo = scan.nextLine();
System.out.println("Nhap thoi gian vao cua: ");
entireTime = scan.nextLine();
}
public void display() {
System.out.println(this);
}
@Override
public String toString() {
return "Booking{" + "bookingNo=" + bookingNo + ", timeNo=" + timeNo + ", entireTime=" + entireTime + '}';
}
public String getBookingNo() {
return bookingNo;
}
public void setBookingNo(String bookingNo) {
this.bookingNo = bookingNo;
}
public String getTimeNo() {
return timeNo;
}
public void setTimeNo(String timeNo) {
this.timeNo = timeNo;
}
public String getEntireTime() {
return entireTime;
}
public void setEntireTime(String entireTime) {
this.entireTime = entireTime;
}
}
Tags:
Phản hồi từ học viên
5
(Dựa trên đánh giá ngày hôm nay)