Hello, if you have any need, please feel free to consult us, this is my wechat: wx91due
In this assignment, you will use OOP to represent, manipulate, and work with solar panels and parking lot projects.
Refer to our Programming Assignments FAQ for instructions on how to install VScode, how to use the command line and how to submit your assignments.
You need time to understand the assignment and to answer the many questions that will arise as you read the description and the code provided.
Refer to our Programming Assignments FAQ for instructions on how to install VSCode, how to use the command line and how to submit your assignments.
- See this video on how to import the project into VSCode and how to submit into Autolab.
The assignment has two components:
1. Coding (70 points) submitted through Autolab. (Due 11/22)2. Reflection (3 points) submitted through a form. (Due 11/27)
- Submit the reflection AFTER you have completed the coding component.
- You cannot resubmit reflections but you can edit your responses before the deadline by clicking the Google Form link, signing in with your netid, and selecting “Edit your response”
Overview
More specifically, you will work with the following:
- A street map containing parking lots (always labeled “P#” where # is a number) and other road features that are solely meant for decorations. Don’t place a solar panel in the middle of a road!
- An Array of parking lot objects, containing info like budget, parking lot, max panels, and capacity.
- An array of Panel objects that contain individual solar panels at particular positions. This array has the same size as the street map, and a certain position [i][j] refers to THE SAME position in the street map.
Implementation
Overview of files provided
- The SolarPanels class contains the methods you will use to work with the panels; you will submit this file to Autolab.
- The Panels class contains information about a SINGLE solar panel. Do not edit or submit to Autolab.
- The ParkingLot class contains information about a parking lot and the project to build panels on that lot. Do not edit or submit to Autolab.
- The AnimatedDriver and TextDriver classes are used to test your methods interactively. Follow the prompts in the terminal or your screen to use the driver. Feel free to edit this file, as it is provided only to help you test your code. It is not submitted and itis not used to grade your code. Do not submit to Autolab.
- In AnimatedDriver, once on a screen (like the map view), press any key to move to the next screen.
- USE TextDriver to test first, it is simpler to use. We suggest that you start with the text driver but once you have a good understanding of the assignment then you may use the graphic driver.
- Both drivers function the same way – if it works on one driver it’ll work on the other.
- Multiple input files are included; they store [varies information depending on what method you’re testing]. You are welcome to create your own input files, as they will not be submitted to Autolab.
- DO NOT add new import statements.
- DO NOT change any of the method’s signatures.
setupStreetMap
To complete this method:
- Set standard input to the file name in parameters by using StdIn.setFile.
- Read the length of the array, given as an integer on one line
- Read the width of the array, given as an integer on one line
- Update streetMap to be an l x w array of Strings
- You will then see l x w Strings representing each value in a position (say [i][j]). Update each [i][j] value in the 2D array with the proper String value.
- StdIn.setFile(filename) opens a file to be read.
- StdIn.readInt() reads the next integer value from the opened file (whether the value is in the current line or in the next line).
- StdIn.readDouble() reads the next double value from the opened file (whether the value is in the current line or in the next line).
- StdIn.readString() reads the next String value from the opened file.
Here is the expected output for this method in the driver using street1.in. NOTE that both drivers will give you the same output — using one is equivalent.
setupParkingLots
To complete this method:
- Set standard input to the file name in parameters by using StdIn.setFile.
- Read the number of items, say n (given as an integer on one line).
- You will see n lines (one line represents one lot) with the following, space-separated. Read each value and add a ParkingLot
- object containing all values in each line to the Array lots.
- The name, as one string
- The maximum number of panels, as an int
- The budget you have, as a double
- The energy capacity, as an int
- The panel efficiency, as a double
- Be sure to initialize lots to be a new Array.
Lots are formatted as {lotName, maxPanels, budget, energyCapacity, panelEfficiency}.
In this method, you’ll go ahead and build the panels on each lot! You will be given a cost per panel.
To complete this method:
- Initialize the instance variable panels to be the same dimensions as streetMap. Panels will contain Panel objects.
- For each parking lot:
- Keep track of the current budget and current panels so far (right now, that’s 0).
- Traverse the streetMap and for each cell, check if:
- The cell equals the lot’s name.
- Adding a new panel doesn’t give you a negative balance (exactly zero is okay).
- The number of panels so far does not exceed the maximum panels in this lot.
- If those conditions are met, add a new panel containing the lot’s efficiency and energy capacity; for whether or not the panel works, we will randomly generate this value.
- StdRandom.uniform() returns a double from 0 up to but not including 1. USE this to get a random double – if it’s less than 0.95 the panel works, if greater than or equal to the panel is broken.
updateActualEfficiency
We will simulate this through a method that passes in a temperature and coefficient we use for efficiency loss.We calculate efficiency loss as follows: coefficient * (temperature - 77). Note that if temperatures are colder than 77 degrees then we will have an efficiency gain. Your task is to update all panels to account for efficiency losses or gains compared to their rated efficiency.
Here is the expected output for this method using street1.in, lots1.in and a cost per panel of $1,000, as well as a temperature of 85 degrees and a coefficient of -0.35. Run all previous methods before running this.
Panels are formatted as {ratedEfficiency, actualEfficiency, electricityGenerated, maxOutput, works}.
This method updates the instance variable, electricityGenerated, to reflect the amount of electricity generated in one day by each solar panel in a project.
We calculate the amount of electricity generated by a solar panel in one day using the following formula: power output in watts * average hours of peak sunlight = daily watt-hours.
The power output of a solar panel is determined by its efficiency. The panels you are installing are 1.5 square meters in size. Direct solar radiation is about 1000 watts per square meter. At 100% efficiency, your panels should produce 1500 watts of electricity. However, at 20% efficiency, for example, your panels are only converting (20 / 100) * 1500 of this potential energy into electricity. That is 300 watts.
Therefore, we calculate the power output of a solar panel using the following formula:
Note that on average New Jersey receives approximately 4 hours of peak sunlight.
Here is the expected output for this method using street1.in, lots1.in and a cost per panel of $1,000, as well as a temperature of 85 degrees and a coefficient of -0.35. Run all previous methods before running this.
Panels are formatted as {ratedEfficiency, actualEfficiency, electricityGenerated, maxOutput, works}.
As you traverse your array of panels, check that you are (1) in the specified parking lot and (2) whether the panel is working. As you find working panels in the specified parking lot, increment your count.
Here is the expected output for this method using street1.in, lots1.in and a cost per panel of $1,000. Run setupStreetMap, setupParkingLots, and insertPanels before testing.
Use P2 as the lot name.
updateWorkingPanels
Once you find a broken panel, update the instance variable, isWorking, to reflect the working status of the panel. This method should return the number of working panels in the project after the repairs have been made.
Here is the expected output for this method using street1.in, lots1.in and a cost per panel of $1,000. Run setupStreetMap, setupParkingLots, and insertPanels before testing.
Panels are formatted as {ratedEfficiency, actualEfficiency, electricityGenerated, maxOutput, works}.Blue indicates a panel works.
Rutgers spends approximately $60 million funding approximately 4.27 million kilowatt-hours of electricity a year.
We calculate the money Rutgers will save by totaling the amount of electricity generated in one year by all of the panels in a project and determining what percent of Rutgers’ electricity needs this meets.
Imagine one solar panel project can produce enough electricity to cover 10% of Rutgers’ yearly electricity needs. Since Rutgers needs 10% less power from their utility provider, their electricity bill would be down to $54 million, meaning they will save $6 million a year on electricity.
Note that in updateElectricityGenerated(), you calculated the watt-hours each solar panel generates in one day. In this method, you will be totaling the amount of electricity generated by all of the panels in a project for the year in kilowatt-hours.
- To find total electricity, add up the electricity used on all panels and multiply by 0.001 to convert to kilowatt-hours.
- Then, multiply that amount by 365 to capture a year’s worth of electricity. Divide that by 4270000 to compare against Rutgers’ needs, and multiply the result by 60 million to calculate the portion of money saved.
Here is the expected output for this method using street1.in, lots1.in and a cost per panel of $1,000, as well as a temperature of 85 degrees and a coefficient of -0.35. Run all previous methods besides countWorkingPanels and updateWorkingPanels before testing.
- YOU MAY only update the methods with the WRITE YOUR CODE HERE line.
- COMMENT all print statements you have written from SolarPanels.java
- DO NOT add any instance variables to the SolarPanels class.
- DO NOT add any public methods to the SolarPanels class.
- DO NOT add/rename the project or package statements.
- DO NOT change the SolarPanels class name.
- YOU MAY add private methods to the SolarPanels class.
- YOU MAY use any of the libraries provided in the zip file.
- DO NOT use System.exit()
You can install VSCode extension packs for Java. Take a look at this tutorial. We suggest:
- Extension Pack for Java
- Project Manager for Java
- Debugger for Java
1. Download SolarPanels.zip from Autolab Attachments.2. Unzip the file by double clicking.3. Open VSCode
- Import the folder to a workspace through File > Open Folder
- You can run your program through VSCode or you can use the Terminal to compile and execute. We suggest running through VSCode because it will give you the option to debug.
- How to debug your code
- If you choose the Terminal:
- first navigate to SolarPanels directory/folder
- to compile: javac -d bin src/*.java
- to execute: java -cp bin AnimatedDriver