Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions RentalProject-1/rental-proj/.idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions RentalProject-1/rental-proj/.idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions RentalProject-1/rental-proj/.idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions RentalProject-1/rental-proj/.idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions RentalProject-1/rental-proj/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions RentalProject-1/rental-proj/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>org.example</groupId>
<artifactId>untitled9</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>19</maven.compiler.source>
<maven.compiler.target>19</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.10.1</version>
</dependency>
</dependencies>
</project>

Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package org.example;

import java.util.ArrayList;

public class AllModules {
public ArrayList<Game> games;
public ArrayList<Book> books=new ArrayList<>();
public ArrayList<Movie> movies;
public ArrayList<Customer> customers=new ArrayList<>();

public ArrayList<Game> getGames() {
return games;
}

public ArrayList<Book> getBooks() {
return books;
}

public ArrayList<Movie> getMovies() {
return movies;
}

public ArrayList<Customer> getCustomers() {
return customers;
}

public void setGames(ArrayList<Game> games) {
this.games = games;
}

public void setBooks(ArrayList<Book> books) {
this.books = books;
}

public void setMovies(ArrayList<Movie> movies) {
this.movies = movies;
}

public void setCustomers(ArrayList<Customer> customers) {
this.customers = customers;
}
}
37 changes: 37 additions & 0 deletions RentalProject-1/rental-proj/src/main/java/org/example/Book.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package org.example;

import java.util.Date;

public class Book extends Item {
String writer;
String publisher;
String bookCover;

public Book(String title, String genre, String writer, Date releaseDate,String publisher,String bookCover, int id,boolean isAvailable ) {
super(title, genre, releaseDate, id,isAvailable);
this.writer = writer;
this.publisher=publisher;
this.bookCover=bookCover;
}

public String getTitle() {
return getName();
}

public String getGenre() {
return genre;
}

public String getAuthor() {
return writer;
}

public Date getReleaseDate() {
return releaseDate;
}

public int getID() {
return returnId();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package org.example;

import java.util.ArrayList;
import java.util.List;

public class Customer {
int id;
String name;
String email;
String phone;
String address;
List<Rental> rentals=new ArrayList<>();
public Customer(String name, String email, String phone, String address, int id) {
this.id = id;
this.name = name;
this.email = email;
this.phone = phone;
this.address = address;
}

public int getId() {
return id;
}

public String getName() {
return name;
}

public String getEmail() {
return email;
}

public String getPhone() {
return phone;
}

public List<Rental> getRentals() {
return rentals;
}

public String getAddress() {
return address;
}
}
41 changes: 41 additions & 0 deletions RentalProject-1/rental-proj/src/main/java/org/example/Game.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package org.example;

import java.util.Date;
// "gameRate": 9,
// "aboutGame": "Embark on an epic adventure as Link",
// "manufacturer": "Nintendo"
public class Game extends Item {
String company;
String aboutGame;
String director;
double gameRate;

public Game(String title, String genre, String company, Date releaseDate, int id,boolean isAvailable,String aboutGame,String director,double gameRate) {
super(title, genre, releaseDate, id,isAvailable);
this.company = company;
this.aboutGame=aboutGame;
this.director=director;
this.gameRate=gameRate;
}

public String getName() {
return title;
}

public String getCompany() {
return company;
}

public String getGenre() {
return genre;
}

public Date getReleaseDate() {
return releaseDate;
}

public int getId() {
return returnId();
}

}
44 changes: 44 additions & 0 deletions RentalProject-1/rental-proj/src/main/java/org/example/Item.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package org.example;

import java.util.Date;

public class Item {
private int id;
String title;
String genre;
Date releaseDate;
boolean isAvailable;

public String getName() {
return title;
}

public String getGenre() {
return genre;
}

public Date getReleasedate() {
return releaseDate;
}

public Item(String name, String genre, Date releaseDate, int id,boolean isAvailable) {
this.id = id;
this.title = name;
this.genre = genre;
this.releaseDate = releaseDate;
this.isAvailable=isAvailable;
}

public void setAvailable() {
isAvailable = true;
return;
}

public boolean isavailable() {
return isAvailable;
}

public int returnId() {
return id;
}
}
54 changes: 54 additions & 0 deletions RentalProject-1/rental-proj/src/main/java/org/example/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package org.example;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

import java.io.*;
import java.io.FileWriter;
import java.util.List;

public class Main {
public static void main(String[] args) throws IOException {
Gson gson = new Gson();
Reader reader = new FileReader("C:\\Users\\NS\\IdeaProjects\\untitled9\\src\\test\\TestYourFork.json");
AllModules allModules = gson.fromJson(reader, new TypeToken<AllModules>() {
}.getType());
Customer Hosein = new Customer("Hosein","hoseinama1383@gmail.com","09906652919","babol",4);
Customer Joshn = allModules.getCustomers().get(0);
Customer Emily = allModules.getCustomers().get(1);
Customer Brown = allModules.getCustomers().get(2);

for (Item tempItem : allModules.getBooks()) {
if (tempItem.returnId() == 3) RentalStore.rentItem(tempItem, Joshn);
else if (tempItem.returnId() == 6) {
RentalStore.rentItem(tempItem, Joshn);
}
}

for (Item tempItem : allModules.getBooks()) {
if (tempItem.returnId() == 1) RentalStore.rentItem(tempItem, Emily);
else if (tempItem.returnId() == 7) {
RentalStore.rentItem(tempItem, Emily);
}
}

for (Item tempItem : allModules.getBooks()) {
if (tempItem.returnId() == 9) RentalStore.rentItem(tempItem, Brown);
else if (tempItem.returnId() == 4) {
RentalStore.rentItem(tempItem, Brown);
}
}
reader.close();
Gson gson1 = new Gson();
String json = gson1.toJson(allModules);
String filePath = "C:\\Users\\NS\\IdeaProjects\\untitled9\\src\\test\\TestYourFork.json";
try {
java.io.FileWriter writer = new FileWriter(filePath);
writer.write(json);
writer.close();
System.out.println("JSON data has been written to the file successfully.");
} catch (IOException e) {
e.printStackTrace();
}
}
}
36 changes: 36 additions & 0 deletions RentalProject-1/rental-proj/src/main/java/org/example/Movie.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package org.example;

import java.util.Date;

public class Movie extends Item {
String director;
String cast;

public Movie(String title, String genre, String director, String cast, Date releaseDate, int ID,boolean isAvailable) {
super(title, genre, releaseDate,ID,isAvailable);
this.genre = genre;
this.director = director;
this.cast = cast;
}


public String getGenre() {
return genre;
}

public String getDirector() {
return director;
}

public String getCast() {
return cast;
}

public Date getReleaseDate() {
return releaseDate;
}

public int getID() {
return returnId();
}
}
Loading