Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.util.*;
- import java.text.*;
- import java.nio.file.Path;
- import java.nio.file.Files;
- import java.nio.file.Paths;
- import java.io.*;
- class Car {
- private String numberPlate;
- public String getNumberPlate (){
- return this.numberPlate;
- }
- public void setNumberPlate (String numberPlate){
- this.numberPlate = numberPlate;
- }
- public String model;
- public String getModel (){
- return this.model;
- }
- public void setModel (String model){
- this.model = model;
- }
- public String colour;
- public String getColour (){
- return this.colour;
- }
- public void setColour (String colour){
- this.colour = colour;
- }
- public int mileage;
- public int getMileage (){
- return this.mileage;
- }
- public void setMileage (int mileage){
- this.mileage = mileage;
- }
- public String accidentHistory;
- public String getAccidentHistory(){
- return this.accidentHistory;
- }
- public void setAccidentHistory (String accidentHistory){
- this.accidentHistory = accidentHistory;
- }
- public int price;
- public int getPrice (){
- return this.price;
- }
- public void setprice(int price{
- this.price = price;
- }
- public Date arrivalDate;
- public Date getArrivalDate (){
- return this.arrivalDate;
- }
- public void setArrivalDate (Date arrivalDate){
- this.arrivalDate = arrivalDate;
- }
- private Date sellingDate;
- public Date getSellingDate (){
- return this.sellingDate;
- }
- public void setSellingDate (Date sellingDate){
- this.sellingDate = sellingDate;
- }
- public CarType carType;
- public CarType getCarType (){
- return this.carType;
- }
- public void setCarType (CarType carType){
- this.carType = carType;
- }
- public Size size;
- public Size getSize (){
- return this.size;
- }
- public void setSize (Size size){
- this.size = size;
- }
- public Transmission transmission;
- public Transmission getTransmission (){
- return this.transmission;
- }
- public void setTransmission (Transmission transmission){
- this.transmission = transmission;
- }
- Car(){
- numberPlate = "";
- model = "";
- colour = "";
- mileage = 0;
- accidentHistory = "";
- price = 0;
- arrivalDate = new Date ();
- sellingDate = new Date ();
- carType = CarType.Saloon;
- size = Size.Large;
- transmission = Transmission.Automatic;
- }
- Car (String numberPlate, String model, String colour, int mileage, String accidentHistory, int price, String arrivalDate, String sellingDate, CarType carType, Size size, Transmission transmission){
- this.numberPlate = numberPlate;
- this.model = model;
- this.colour = colour;
- this.mileage = mileage;
- this.accidentHistory = accidentHistory;
- this.price = price;
- SimpleDateFormat dateType = new SimpleDateFormat("yyyy-mm-dd");
- try {
- this.arrivalDate = dateType.parse(arrivalDate);
- this.sellingDate = dateType.parse(sellingDate);
- }
- catch (ParseException e){
- System.out.println("wrong date");
- }
- this.carType = carType;
- this.size = size;
- this.transmission = transmission;
- }
- }
- enum CarType {
- Hatchback (5,4), Saloon(5,5), SUV(5,5), MPV(5,7), Van(5,3), Coupe(2,2);
- private int doors;
- private int seats;
- CarType (int doors, int seats){
- this.doors = doors;
- this.seats = seats;
- }
- }
- enum Size {
- Large("Large"), Small("Small");
- private String size;
- Size (String size){
- this.size = size;
- }
- public String GetSize (){
- return this.size;
- }
- public void SetSize (String size){
- this.size = size;
- }
- }
- enum Transmission {
- Automatic("Automatic"), Manual("Manual");
- private String transmission;
- Transmission(String transmission){
- this.transmission = transmission;
- }
- }
- class Person {
- protected String username, password;
- }
- class Staff extends Person {
- public void AddCars(ArrayList<Car>cars){
- String filename = "Preboot:\\Users\\maximolivson\\IdeaProjects\\untitled\\src\\com\\company\\maximolivson\\IdeaProjects\\ArrayList.txt";
- String output = "";
- try{
- output = Files.lines (Paths.get(filename)).reduce("",(a,b)->a+"\n"+b);
- }
- catch (IOException fail){
- System.out.println(fail.getMessage());
- }
- System.out.println(output);
- }
- public void AddCar(Car car){
- }
- public void SellCar(Car car, ArrayList <Car>cars){
- for (Car temporaryCar:cars){
- if(car.getNumberPlate()== temporaryCar.getNumberPlate()){
- temporaryCar.setSellingDate(new Date());
- break;
- }
- }
- }
- public void PrintCars(){
- }
- public void Search2(Car car){
- }
- public void Search(String model, Transmission transmission, ArrayList<Car>cars){
- ArrayList <Car>selectedCars = new ArrayList<Car>();
- for (Car temporaryCar:cars){
- if (car.getModel() == model && car.getTransmission() == transmission){
- selectedCars.add(temporaryCar);
- }
- }
- }
- public void Search3(Car car){
- }
- public void CalculateRevenue(Car car){
- }
- }
- class Customer extends Person {
- }
- class Admin extends Staff {
- }
- public class Main {
- public static void main(String[] args) {
- ArrayList <Car>cars = new ArrayList<Car>();
- Staff Jon = new Staff();
- Jon.AddCars(cars);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement