Collaboration/Plagiarism Policy: This assignment is individual work. Sending, receiving, posting, reading. viewing, comparing, or otherwise copying...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Collaboration/Plagiarism Policy: This assignment is individual work. Sending, receiving, posting, reading. viewing, comparing, or otherwise copying any part of course assignments or solutions is not allowed except when explicitly permitted in assignment instructions. This includes solutions from other students in the course, past or present. See the course syllabus for penalties for collaboration policy violations. Learning Objectives • Implement code that utilizes String and primitive variable types. • Create a Java object (class) with getters and setters. • Develop Java classes that use instances of another class. • Implement an ArrayList to store a collection of items. • Implement and utilize static methods appropriately. Test written code using main method testing. Grading Rubric • 70% Methods function properly • 30% Design and readability (See Coding Style Guide) - 5% Correct indentation - 5% Naming Conventions - 10% Well-commented (including the test code within your nain() method) 10% Testing in main() Instructions: Even Instagram started somewhere. In this assignment you will be breaking ground on a photography application, beginning with the foundational classes PhotoLibrary and Photograph. These classes will define what it means to be a photograph and PhotoLibrary and how they interact; specifically a PhotoLibrary may contain photographs a user posts to their photo feed. You must adhere to the following requirements (guidelines) when creating your classes: Photograph class: For this assignment we will consider a Photograph to be just a caption and filename. • Fields: caption (private) A String; the caption of the photograph. Once created this will never change, so you are welcome to make it final if you want. filename (private) A String; the filename of the photograph. Once created this will never change, so you are welcome to make it final if you want. Constructors: Provide one constructor that takes a caption and filename (in that order). • Accessors (AKA getters): Provide public methods that return references to the caption and filename fields. You must use the standard naming convention for these. • Mutators (AKA setters): None. Once a photograph exists, its caption and filename are fixed. • Other Methods: - public boolean equals (Object o) Folowing the standard rules and conventions as shown in class, return true if the Pho- tograph object passed to equals() with caption and filename strings mateh (are equal to) the caption and filename strings of the current Photograph object; otherwise, return false. public String tostring() A means to print out a Photograph object. Generate a String that shows the values of the fields caption and filename. Any reasonable implementation of this is acceptable. PhotoLibrary class: A PhotoLibrary has a name and a list of photos the user has posted to their photo feed, but both of those can change. To keep libraries straight, they also have a mumerical ID. • Fields: name (private) A String containing the PhotoLibrary's name in whatever form it was provided. id (private) An int containing the PhotoLibrary's unique id. Once set this will never change, so yon are welcome to uake it final if you want. - photos (private) An ArrayList <Photograph> of photos the user has post ed to their feed in this library. You are required to use ArrayList<Photograph>, not an array or other kind of list. Constructors: Provide one constructor that takes a name and an id in that order. Make sure you follow good standard Java practice and initiulize all your fields in the constructor. • Accessors (AKA getters): Provide public methods that return the value of the id fiekl and references to the name and photos fiekls. You must use the standard naming convention for these. • Mutators (AKA setters): Write a setter for the name field but not for id (which cannot change) and not for the photos ficld (which will be changed by other methods outlined below). You mst tuse the standard naming convention for the mutator. • Other Methods: - public boolean addPhoto (Photograph p) Add the Photograph p to the list of the current objeet's photos feed if and only if it was not already in that list. Return true if the Photograph was added; return false if it was not added. public boolean hasPhoto (Photograph p) Return true if the eurrent object has p in its list of photos. Otherwise return false. public boolean erasePhoto (Photograph p) Once a photo is available online, it's hard to delete. However, this particular PhotoLibrary may delete the photo from their feed. If Photograph p is in the current PhotoLibrary object's list of Photographs, remove p from the current object's list. Return true if the Photograph was removed or false if it was not there. - public int numPhotographs () Return the munber of Photographs the current object. has taken (in photos). - public boolean equals (Object o) Folowing the standard rules and conventions as shown in elass, return true if the current PhotoLibrary object's id vahue is equal to the id value of the PhotoLibrary object passed to equals(). Otherwise, return false. - public String tostring() A means to print out a PhotoLibrary object. Generate a String that shows the values of the fields name, id, and photos. Any reasonable implementation of this is acceptable. - public static ArrayList<Photograph> commonPhotos (Photolibrary a, Photolibrary b) Return an ArrayList<Photograph> of the photos that both PhotoLibrary a and Pho- tolibrary b have posted to their feeds. Use the equals method of the Photograph class to determine if two Photograph objects represent the same photograph. - public static double similarity(Photol.ibrary a, Photol.ibrary b) Returns a measure of how similar the photo feeds are between PhotoLibrary a and Pho- tolibrary b, in ters of a mumerical value between 0 and 1. If either Photol.ibrary does not have any photos, the result is 0.0. Otherwise, it is the number of connonPhotos to both libraries divided by smaller of the mumber of photos in a's feed and the mumber of photos in b's feed. Reminder: Java respects types, so the integer division of 3 / 4 gives integer 0, while inclxding a float or double in the division 3 / 4.0 gives 0.75. NOTE: For each of the methods, you must write the exact method signature as specified. Testing: We expect that you will add a main() method to test your code. We require at least two tests of each of the methods listed above, excluding the getters and setters. Part of the Design and Readability grade is based on of your main method testing. Style: You must follow the Coding Style Guide. This includes: • Correct naming conventions, inclxding appropriate camelCasing and TitleCasing. • Comment each file, with a block at the top of the file denoting assignment information and comments for each field and method of your classes. You should also comment portions of your code that may be difficult to follow. We would like you to get into the habit of commenting your code. This adds to the readability of your code which contributes to "good quality" code. • Use correct indentation. Eclipse makes this casy: select all code and choose "Correct Inden- tation" or Control-I (Windows/Limux) or Command-I (Mac). • Do not put your classes into a package. (If you don't know what this means, don't worry about it.) • If two methods share identical logic, you should factor that out into a separate method (a "helper" method). Submission: You must submit on Web-CAT. Submit Photograph.java and Person. java. They must have these names exactly (including capitalization). Make sure you do not submit the .class fikes. Each time you submit, you will be given a score for the 70 points listed abOve. If you pass all of our tests you will get the full 70 points. If you fail our tests your grade will be based on how many tests you pass. If you fail a test, Web-CAT will giwe you a small hint about what was being tested. If your code does not compile, you will receive a 0 and Web-CAT will try to point out why it was unable to compile your code. (Usilally, this is because something was spelled differently than specified nbove. Be sure to follow all naming conventions for getters and setters.) During this assignment, you will be allowed an unlimited mumber of submission attempts. To submit on Web-CAT you need to zip up your files. If you are not sure how to do this you can follow the instructions below: 1. Right-click your arc folder in Eclipse 2. Sekecet Export..., General, Archive File 3. Check the java files you want to submit 4. Browse to a save location you can find again 5. Finish 6. In a browser, go to veb-cat.cs. vt.edu 7. Log in 8. Click the Subuit button next to an assignment 9. Browse and select the zip file you just created 10. Upload 11. Confirm Note, if the link above is not redirecting you properly, use the following URL: http://veb-cat.cs.vt.edu/Veb-CAT/NebObjects/ieb-CAT. voa Collaboration/Plagiarism Policy: This assignment is individual work. Sending, receiving, posting, reading. viewing, comparing, or otherwise copying any part of course assignments or solutions is not allowed except when explicitly permitted in assignment instructions. This includes solutions from other students in the course, past or present. See the course syllabus for penalties for collaboration policy violations. Learning Objectives • Implement code that utilizes String and primitive variable types. • Create a Java object (class) with getters and setters. • Develop Java classes that use instances of another class. • Implement an ArrayList to store a collection of items. • Implement and utilize static methods appropriately. Test written code using main method testing. Grading Rubric • 70% Methods function properly • 30% Design and readability (See Coding Style Guide) - 5% Correct indentation - 5% Naming Conventions - 10% Well-commented (including the test code within your nain() method) 10% Testing in main() Instructions: Even Instagram started somewhere. In this assignment you will be breaking ground on a photography application, beginning with the foundational classes PhotoLibrary and Photograph. These classes will define what it means to be a photograph and PhotoLibrary and how they interact; specifically a PhotoLibrary may contain photographs a user posts to their photo feed. You must adhere to the following requirements (guidelines) when creating your classes: Photograph class: For this assignment we will consider a Photograph to be just a caption and filename. • Fields: caption (private) A String; the caption of the photograph. Once created this will never change, so you are welcome to make it final if you want. filename (private) A String; the filename of the photograph. Once created this will never change, so you are welcome to make it final if you want. Constructors: Provide one constructor that takes a caption and filename (in that order). • Accessors (AKA getters): Provide public methods that return references to the caption and filename fields. You must use the standard naming convention for these. • Mutators (AKA setters): None. Once a photograph exists, its caption and filename are fixed. • Other Methods: - public boolean equals (Object o) Folowing the standard rules and conventions as shown in class, return true if the Pho- tograph object passed to equals() with caption and filename strings mateh (are equal to) the caption and filename strings of the current Photograph object; otherwise, return false. public String tostring() A means to print out a Photograph object. Generate a String that shows the values of the fields caption and filename. Any reasonable implementation of this is acceptable. PhotoLibrary class: A PhotoLibrary has a name and a list of photos the user has posted to their photo feed, but both of those can change. To keep libraries straight, they also have a mumerical ID. • Fields: name (private) A String containing the PhotoLibrary's name in whatever form it was provided. id (private) An int containing the PhotoLibrary's unique id. Once set this will never change, so yon are welcome to uake it final if you want. - photos (private) An ArrayList <Photograph> of photos the user has post ed to their feed in this library. You are required to use ArrayList<Photograph>, not an array or other kind of list. Constructors: Provide one constructor that takes a name and an id in that order. Make sure you follow good standard Java practice and initiulize all your fields in the constructor. • Accessors (AKA getters): Provide public methods that return the value of the id fiekl and references to the name and photos fiekls. You must use the standard naming convention for these. • Mutators (AKA setters): Write a setter for the name field but not for id (which cannot change) and not for the photos ficld (which will be changed by other methods outlined below). You mst tuse the standard naming convention for the mutator. • Other Methods: - public boolean addPhoto (Photograph p) Add the Photograph p to the list of the current objeet's photos feed if and only if it was not already in that list. Return true if the Photograph was added; return false if it was not added. public boolean hasPhoto (Photograph p) Return true if the eurrent object has p in its list of photos. Otherwise return false. public boolean erasePhoto (Photograph p) Once a photo is available online, it's hard to delete. However, this particular PhotoLibrary may delete the photo from their feed. If Photograph p is in the current PhotoLibrary object's list of Photographs, remove p from the current object's list. Return true if the Photograph was removed or false if it was not there. - public int numPhotographs () Return the munber of Photographs the current object. has taken (in photos). - public boolean equals (Object o) Folowing the standard rules and conventions as shown in elass, return true if the current PhotoLibrary object's id vahue is equal to the id value of the PhotoLibrary object passed to equals(). Otherwise, return false. - public String tostring() A means to print out a PhotoLibrary object. Generate a String that shows the values of the fields name, id, and photos. Any reasonable implementation of this is acceptable. - public static ArrayList<Photograph> commonPhotos (Photolibrary a, Photolibrary b) Return an ArrayList<Photograph> of the photos that both PhotoLibrary a and Pho- tolibrary b have posted to their feeds. Use the equals method of the Photograph class to determine if two Photograph objects represent the same photograph. - public static double similarity(Photol.ibrary a, Photol.ibrary b) Returns a measure of how similar the photo feeds are between PhotoLibrary a and Pho- tolibrary b, in ters of a mumerical value between 0 and 1. If either Photol.ibrary does not have any photos, the result is 0.0. Otherwise, it is the number of connonPhotos to both libraries divided by smaller of the mumber of photos in a's feed and the mumber of photos in b's feed. Reminder: Java respects types, so the integer division of 3 / 4 gives integer 0, while inclxding a float or double in the division 3 / 4.0 gives 0.75. NOTE: For each of the methods, you must write the exact method signature as specified. Testing: We expect that you will add a main() method to test your code. We require at least two tests of each of the methods listed above, excluding the getters and setters. Part of the Design and Readability grade is based on of your main method testing. Style: You must follow the Coding Style Guide. This includes: • Correct naming conventions, inclxding appropriate camelCasing and TitleCasing. • Comment each file, with a block at the top of the file denoting assignment information and comments for each field and method of your classes. You should also comment portions of your code that may be difficult to follow. We would like you to get into the habit of commenting your code. This adds to the readability of your code which contributes to "good quality" code. • Use correct indentation. Eclipse makes this casy: select all code and choose "Correct Inden- tation" or Control-I (Windows/Limux) or Command-I (Mac). • Do not put your classes into a package. (If you don't know what this means, don't worry about it.) • If two methods share identical logic, you should factor that out into a separate method (a "helper" method). Submission: You must submit on Web-CAT. Submit Photograph.java and Person. java. They must have these names exactly (including capitalization). Make sure you do not submit the .class fikes. Each time you submit, you will be given a score for the 70 points listed abOve. If you pass all of our tests you will get the full 70 points. If you fail our tests your grade will be based on how many tests you pass. If you fail a test, Web-CAT will giwe you a small hint about what was being tested. If your code does not compile, you will receive a 0 and Web-CAT will try to point out why it was unable to compile your code. (Usilally, this is because something was spelled differently than specified nbove. Be sure to follow all naming conventions for getters and setters.) During this assignment, you will be allowed an unlimited mumber of submission attempts. To submit on Web-CAT you need to zip up your files. If you are not sure how to do this you can follow the instructions below: 1. Right-click your arc folder in Eclipse 2. Sekecet Export..., General, Archive File 3. Check the java files you want to submit 4. Browse to a save location you can find again 5. Finish 6. In a browser, go to veb-cat.cs. vt.edu 7. Log in 8. Click the Subuit button next to an assignment 9. Browse and select the zip file you just created 10. Upload 11. Confirm Note, if the link above is not redirecting you properly, use the following URL: http://veb-cat.cs.vt.edu/Veb-CAT/NebObjects/ieb-CAT. voa
Expert Answer:
Answer rating: 100% (QA)
Program Photographjava Create a class Photograph public class Photograph Instance variables private final String caption private final String filename Constructor public PhotographString captionString ... View the full answer
Related Book For
Cost Management A Strategic Emphasis
ISBN: 978-0078025532
6th edition
Authors: Edward Blocher, David Stout, Paul Juras, Gary Cokins
Posted Date:
Students also viewed these mathematics questions
-
2017 Subaru Legacy Sedan 4 cyl 4 Door Sedan with 136,300 miles. The customer complaint is that when they put their Right Directional on it has a steady clicking/blinking sound coming from their...
-
Writing and Presenting a Research Report As Brown, Suter, and Churchill (2014) indicate in the Basic Marketing Research textbook, a marketing researcher will almost always be expected to develop a...
-
Define what it means to perform decision making under assumed certainty, risk, and uncertainty.
-
A manufacturing company reports the following information for the month of May. Note: Assume all raw materials were used as direct materials. Activities for May Advertising expense Raw materials...
-
Refer to the Journal of & Applied Psychology (June 2002) completely randomized design study to compare the mean commercial recall scores of viewers of three TV programs, presented in Exercise 9.28...
-
In the context of advanced file systems, such as ZFS or Btrfs, how do mechanisms like copy-on-write, snapshots, and data deduplication contribute to data integrity and system resilience ?
-
A coach has been trying to evaluate the accuracy of a baseball pitcher. After two years of studying, he proposes a function that can be presented as the accuracy of any pitcher: \[ \mathrm{Acc}=f(V,...
-
The following is a partial trial balance for the Green Star Corporation as of December 31, 2011: 100,000 shares of common stock were outstanding throughout 2011. Required: 1. Prepare a single-step...
-
Relationship marketing, as defined by Cuofano (2023), revolves around businesses and their brands establishing lasting connections with customers. The primary objective of relationship marketing is...
-
The DuPont formula defines the net return on shareholders equity as a function of the following components: Operating margin Asset turnover Interest burden Financial leverage Income tax rate...
-
Work Group" is a vital tool in healthcare organizations. Assume you are the COO of a healthcare institution. Develop a set of guidelines that you would require your work groups to follow to increase...
-
What are the advantages of divisionalisation?
-
Are there ever times when the task is so important that concern for the social dimension of the group must be ignored?
-
What are the disadvantages of role fixation?
-
What relationship do stability and change have in groups?
-
This is a depiction of a true storythe rise and fall of stockbroker Jordan Belfort (Leonardo DiCaprio). This movie is not for the faint at heart. There is very graphic sexual content and vulgarity....
-
LaneScapes Incorporated Transactions Background LaneScapes Incorporated is a newly founded corporation in Oregon that provides premium ecologically conscious landscaping services in Lane County....
-
As indicated by mutual fund flows, investors tend to beat the market seek safety invest in last year's winner invest in last years loser
-
RTI Company's master budget calls for production and sales of 18,000 units for $81,000; variable costs of $30,600; and fixed costs of $20,000. The company incurred $32,000 of variable costs to...
-
Norton Industries, a manufacturer of cable for the heavy construction industry, closes its books and prepares financial statements at the end of each month. The statement of cost of goods sold for...
-
As indicated in the Real-World Focus (RWF) item on page XXX, consumers (including businesses and local governments) interested in using solar power generally have an option to purchase or to lease...
-
In the previous example, suppose that these are all of the entries in Freedonias BOP table. Calculate the value of errors and omissions. TABLE 11.2 Balance-of-Payments Example Merchandise exports...
-
Consider the demand and supply curves in Exercise 13. DATA FROM EXERCISE13 Suppose that the domestic demand and supply for shoes in a small open economy are given by. where P denotes price and Q...
-
Repeat Exercise 6 under the assumption that instead of a fall in demand for foreign exchange, there is an increase in supply. data from exercise 6 Credit entries in a countrys balance of payments...
Study smarter with the SolutionInn App