0% found this document useful (0 votes)
9 views6 pages

Course: Eecs1022 Pe2: Add Wechat For More Information Contact Us

The document outlines a Java programming course (EECS1022) led by tutor John, covering topics such as 2D arrays, object-oriented programming, and library system simulation. It includes examples and requirements for coding assignments, emphasizing the creation of classes with specific attributes and methods. Additionally, it provides contact information for further inquiries and encourages practice through homework questions.

Uploaded by

xiejohn44
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views6 pages

Course: Eecs1022 Pe2: Add Wechat For More Information Contact Us

The document outlines a Java programming course (EECS1022) led by tutor John, covering topics such as 2D arrays, object-oriented programming, and library system simulation. It includes examples and requirements for coding assignments, emphasizing the creation of classes with specific attributes and methods. Additionally, it provides contact information for further inquiries and encourages practice through homework questions.

Uploaded by

xiejohn44
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Course: EECS1022 PE2

Tutor:John

Email: [email protected]

Add WeChat for more information


Contact Us
Tel: 416-551-0667
Web: www.futureupinc.com
Address: Unit 909 – 250 Consumers Road, Toronto
Future Up Education EECS1022 Tutor:John

往期知识点回顾

String.format

String class static method .

Return the string

Format

Example

Copyright Reserved by Future Up – John 1


A better future.
Future Up Education EECS1022 Tutor:John

1 2D array

两个指针在游动

应用 : Matrix

可能错误:index out of bound exception

Write a Java program that takes in a two-dimensional array of integers and


outputs the sum of the elements in each row. The program should prompt the
user to enter the number of rows and columns in the array and then initialize
the array with random integers between 1 and 10. After initializing the array,
the program should output the sum of the elements in each row.

Example Input and Output: Enter the number of rows: 3 Enter the number of
columns: 4 The 2D array is: 2 6 8 4 9 7 1 5 10 3 2 8 The sum of elements in
row 0 is: 20 The sum of elements in row 1 is: 22 The sum of elements in row 2
is: 23

Copyright Reserved by Future Up – John 2


A better future.
Future Up Education EECS1022 Tutor:John

2 OOP

Create class consist of attribute,constructor,method that satisfied the


requirement

1 分析题目

2 理解需求

3 分清楚 static or non static

创造 method 与 attribute

Constructor

4 Coding

5 try test case

6 Debug

Copyright Reserved by Future Up – John 3


A better future.
Future Up Education EECS1022 Tutor:John

You are given a requirement to create a program to simulate a library system.


Write a Java program that includes the following classes and functionalities:

1. Book class: a class that represents a book. It should have the following
attributes: title, author, publication year, and whether the book is
available or checked out.
2. User class: a class that represents a library user. It should have the
following attributes: name and a list of books that the user has
borrowed.
3. Library class: a class that represents a library. It should have the
following attributes: a list of books in the library, and a list of
users who have registered with the library.
4. The Book class should have the following methods:
o checkOut(): A method that sets the book to checked out
o checkIn(): A method that sets the book to available
o isAvailable(): A method that returns true if the book is
available, false otherwise
o toString(): A method that returns a formatted string
representation of the book's properties
5. The User class should have the following methods:
o borrowBook(): A method that adds a borrowed book to the list of
borrowed books
o returnBook(): A method that removes a returned book from the list
of borrowed books
6. The Library class should have the following methods:
o addBook(): A method that adds a book to the library
o removeBook(): A method that removes a book from the library
o registerUser(): A method that adds a user to the list of library
users
o deregisterUser(): A method that removes a user from the list of
library users

Write a main function that creates a Library instance, adds some books to the
library, registers some users, and then simulates user activity by having some
users borrow and return books. Ensure that the state of books and users is
updated properly at all times.

Note:

• You can implement any additional methods you think necessary to make
this program complete.

Copyright Reserved by Future Up – John 4


A better future.
Future Up Education EECS1022 Tutor:John

• You should use encapsulation and create instance variables and


getters/setters for all attributes that need them.

本章总结

Practice Question & Homework

Copyright Reserved by Future Up – John 5


A better future.

You might also like