GithubHelp home page GithubHelp logo

Topic: davis-tech Goto Github

Some thing interesting about davis-tech

Related Topics:

👇 Here are 18 public repositories matching this topic...

  • bell-kevin / box

    davis-tech,Previously, you wrote a project for rectangles. This one is similar but can create a 3D object (box) as well as a 2D one (paper). Create a class named Box, with instance variables for length, width, and height. Create a constructor with no parameters that sets the instance variables to 1. Create an overloaded constructor that needs 2 integer parameters for a 2D object, which sets the length and width, and stores 0 for the height. Create an overloaded constructor that needs 3 integer parameters for a 3D object, which sets the length, width, and height of the object. You do NOT need to create “set” and “get” methods for the 3 instance variables, you’ll be using the constructors only and direct access to the instance variables. Create 3 different methods to calculate the area of a 2D object, the perimeter of a 2D object, and the volume of a 3D object. You don’t have to test the kind of object, just do the calculations and return the answer. Create a Boolean method that checks if the object is a cube – if all 3 measurements are the same, it is a cube. Create a Boolean method that checks if the object is a box – if all 3 measurements are greater than 0, it is a box. If it is not a box, it is a flat object, only 2D – one of the measurements is 0. Create a Boolean method that checks if the flat object is a square – length and width are the same. Create a display method that prints out information about the object. Use an IF-Else IF structure to determine the kind of object – cube, box, square, rectangle. Check first if it is a cube – if yes, also print out the volume. If it’s not a cube, next check if the object is a box – if yes, print out its measurements and volume. If it’s not a cube or box, check if the object is a flat square – if yes, print out its measurements, perimeter and area. If not a cube, box, or square, check if the object is a rectangle – if yes, print out the measurements, perimeter, and area. Note that each object will only display one of these results. If the object is a cube, print those results and exit the If-Else If structure. That’s why you are using an If-Else If structure, so there is only one block of code executed for each call to this method. Write a driver class that instantiates or creates 4 Box objects – a cube, a box, a flat square, and a flat rectangle. Print out the name you gave to an object, then display its information. Repeat for all of the objects. Notice how short it becomes when you use constructors instead of using a set method for every dimension of the objects.

    User: bell-kevin

    class-method object-oriented-programming datc davis-tech
  • bell-kevin / carnival

    davis-tech,The final project is a program that simulates a carnival, and lets the user make a journey through that carnival, playing games and gathering prizes, eating carnival food, taking rides. Final Project Carnival In this project, you will simulate a carnival and one customer’s journey through that carnival. Imagine a carnival with an entrance booth. You, the customer, walk up to the booth and buy some tickets for the attractions inside. Once inside the carnival, you walk up to a game, find out how many tickets it costs to play, and if you have enough, you hand over that number of tickets and play the game. You either win a prize or lose the game. If you win, you get a prize and carry it with you (in a backpack in this simulation) as you continue through the carnival. If you want to get on one of the rides, you hand over the required number of tickets and enjoy the ride – there are no prizes. If you want to eat or drink, you buy that choice and hold it in your hand – so you can only have 2 food items at a time, one in each hand. You have to take time out to eat a food item and free up a hand in this simulation. When you run out of tickets, you can purchase more. When you are done, you exit the carnival. Now consider how to simulate that experience in a project. The project itself is the representation of the carnival. At a carnival, you have rides, games, and food stands, and of course you need customers. Those are each classes in this project. Each object needs a name. The rides, games, and food stands need information about how many tickets it costs. The customer needs information about how many tickets he holds. Notice that this information is known to the customer so you need a method to check how many tickets the customer has, or better yet, a method to check if the customer has enough tickets for a specific game or ride or food. That simulates the carnival worker telling the customer that a ride costs 6 tickets, for example – the customer looks at his tickets to determine if he has enough for that cost of 6, rather than looking at the total he has at the moment. If the customer has enough tickets, then the customer hands over that number – the carnival worker does not reach into the customer’s hands or pockets to grab the tickets. To simulate that, the customer needs a method to use tickets for a specific ride or game or food. The customer holds his prizes, adds more prizes, and can list all his prizes. The customer can hold at most 2 food items, one in each hand, and when one is consumed, that hand becomes empty. To play a game, simulate the result by generating a random number from 1 to 4 – if the number is 1, the customer won the best prize; if the number is 2, the customer won a medium prize, 3 is a small prize, and 4 is no prize, the customer lost the game. Here are several sample sessions that show parts of the overall project. For this session, the games are Water Shooter, Balloon Dart Toss, and Ring Toss; each costs 4 tickets. The rides are a Ferris wheel and a carousel; each costs 6 tickets. The food items are a drink, a hot dog, popcorn, and cotton candy. The details are: Prizes for Water Shooter: stuffed bear, plastic bear, bear key chain Prizes for Balloon Dart Toss: stuffed tiger, plastic tiger, tiger key chain Prizes for Ring Toss: stuffed pig, plastic pig, pig key chain Food: soda = 3 tickets; hot dog = 5 tickets; popcorn = 5 tickets; cotton candy = 5 tickets. Session for food: For food purchases, the customer can have at most 2 food items, one for each hand. If both hands are holding food, it is not possible to purchase another food item. Session for food: For food purchases, the customer can have at most 2 food items, one for each hand. If both hands are holding food, it is not possible to purchase another food item. There is an option to eat food, which will free up the hand for the item eaten. Session where customer had drink in hand 1, hot dog in hand 2, consumed the drink first, now will eat the hot dog. Notice that the hand number can remain fixed, doesn’t indicate first or second item but item in hand 1 versus item in hand 2. Session for ending the Carnival visit when there were NO prizes won: Requirements • You must use one array and one array list, and you must use a for-each loop. • You must use a switch statement. • You must have the following classes: customer, game, ride, food, as well as the main class • The food and ride classes will not print anything directly to the screen. Do not use any System.out.print statements in these classes. • The game class will print directly to the screen in the play method to echo the name of the game being played and to specify the result. • The customer class will print directly to the screen only for the method to eat food, to echo the name of the food. • You must not have duplication of code. You can create additional methods to handle processes that occur in multiple places in the code. • You may select your own games, rides, and food, the number of tickets for each, the prizes for the games. Make the prizes distinct, different for every game and level of each game. • You must test every method with both good and bad input, and bad input must generate helpful descriptive messages.

    User: bell-kevin

    object-oriented-programming datc davis-tech davis-technical-college carnival final-project
  • bell-kevin / coursegradebook

    davis-tech,Create a project that simulates a grade book for a class. Use a 2D array of integers, one row for each student, one column for each test score for that student. Set up the program for any number of students and any number of tests, and ask the user for those numbers. Test the program with 3 students that each have 3 test scores. The CourseGrades application should use a GradeBook class that has instance variables for the number of students and the number of grades, and the 2D array to contain those values. The constructor will use parameters for the number of students and the number of tests to instantiate the 2D array of the proper size. Use these methods: getGrades() to prompt the user for the test grades for each student showGrades() to display the grades for the class studentAvg() to display the average of the test scores for a specific student testAvg() to display the average of the scores for all students for a specific test Each of those methods does its own work to request the user input about specific data and for printing to the screen. The driver class asks the user for the number of students and number of tests and passes that to the constructor to create the gradebook. The driver class needs to ask the user for the next action – show all grades, show the average for a specific student, show the average for a specific test, or exit the program. This needs to loop so the user can continue to interact with the program as often as they wish. Be sure to validate the input. Remember that arrays begin in position 0. Be sure to compensate so that when displaying information about the first student or test, you display “1”, not “0”. When asking the user to select a student or test, the user will input the human-friendly value of 1, 2, or 3 – be sure to compensate for the computer’s version of 0, 1, or 2. It’s very important that the user doesn’t have to know that computers start counting at 0 – keep your on-screen interactions human-friendly. Take a screenshot of your program execution that matches this sample session. Then run it again with a different set of test scores for the students, and check that you get good results for every student’s average and every test’s average. Take a screenshot of that execution.

    User: bell-kevin

    object-oriented-programming datc davis-tech davis-technical-college
  • bell-kevin / drawingshapes

    davis-tech,This project does not require a class, because we aren’t going to instantiate any objects. It uses class methods, specifically the main method plus a few more. Create a project named “Ch7Draw”. You will add class methods above the main method. Remember that class methods need the keyword “static” in the heading. To draw a bar of asterisks across a line, we will use a method named “drawBar”. It needs to know how many times an asterisk should appear on the line, so it needs an integer parameter. In your project, create a class method named “drawBar”. This method uses a FOR loop to print a single asterisk character repeatedly, the number of times passed in to the method. After the loop completes, the System.out.println() command ends the line and positions the cursor at the left edge of the next line on the screen. The main method tests this drawBar method. Here, there is another FOR loop that calls the drawBar() method with different values for the argument. The first time, the index is 1, so drawBar(1) prints a single asterisk on the line. The second time through the loop, the index is 2, so drawBar(2) prints two asterisks on the line. This continues for 6 lines, because that was hard-coded into the For loop. Run the project to make sure it works so far. Now, modify the program to be able to draw a box. That requires 2 values, length across the line (width) and number of lines (height). Create a class method named “drawBox” that accepts those 2 parameters. We already have a method that can draw a line across the page, to the width specified. We need to repeat that action for the number of lines or height specified, so the drawBox method will need to call the drawBar method multiple times. Now that the basic project exists, you need to modify it to ask the user how big a box to draw, and also to ask if they want the default marker (asterisk or *) or if they want to specify the marker. Create another drawBar method that adds a parameter for the marker, and another drawBox method that adds a parameter for the marker. This overloads both methods. In the main method, after the code already written to test the drawing methods, ask the user for the dimensions of the box, then ask if they want the default marker or if they want to specify the marker. Use Y or N for the answer, but allow the user to type it in upper or lower case. Then call the method that will draw such a box, with the default marker (the code you already have) or one with a new specific marker (the new methods that overloaded the previous methods). Note that if the user said to use the default marker, the code should call the existing method that displays the box with asterisks – no change from the previous version of the code. If the user said to use a specific marker, the code should call the overloaded versions of the methods that have that specified marker passed in as one of the parameters. Run the program -- you may use any width and height values you choose, and any character to draw the box. Take a screenshot of the results. Next, modify the project so that it does not draw the right triangle or the box with the hard-coded measurements. Now, the project should ask the user if it should draw a box, and if the answer is yes, ask for the needed parameters and draw that box. Repeat, so that the project can draw more than one box, until the user says to stop. Run your program and test the Y and N responses to both questions, as you see above, using whatever box measurements you wish. Be sure to request a box with the default marker and another box with a specific marker. Take a screenshot of the results. Submission: the specified screenshots, and the root folder for the project Pay careful attention to the rubric for this assignment. Remember the standards that apply to every project. Note that you must use correct formatting in the code -- appropriate indentation is most important. You can use Shift-Alt-F to have NetBeans automatically format the code correctly. If the formatting is incorrect, it will be returned to you for changes with a grade of zero. Note: You need to submit the whole project for these assignments. In File Explorer, go to the location where you created the project. There will be a folder with the name of your project -- that is the root folder of the project. If you submit the root folder of the project, the instructor can run it on a different machine to grade it. If you don't submit the proper folder, it won't run on another machine, and the assignment will be marked with a zero.

    User: bell-kevin

    class-method object-oriented-programming datc davis-tech
  • bell-kevin / fleetinventory

    davis-tech,This project simulates the inventory for a fleet of cars. The fleet is an array of Car objects. A Car has a name and an ArrayList of Miles Per Gallon (MPG) objects. An MPG object has variables for miles, gallons, and miles per gallon, which is calculated in the constructor. The driver class will instantiate 3 Car objects and store them in an array, then add anonymous MPG objects to the ArrayList of MPG objects for each Car. This will be coded directly in the driver, no user input at this point. Using a For-Each loop, the project displays the name of the car, its total MPG and a count of the number of trips for each car. Next, the program asks the user if they want to see the MPG for the individual trips for a single car. If the answer is yes, the user enters any part of the name of the car of interest. Using another For-Each loop, the program goes through the cars to see if the input string appears anywhere in the name of the car, and when it is found, displays each of the MPG objects for that car. You may use any car names you want, and any number of trips for each car. Make sure there are different numbers of trips – look at the example, where it shows 5, 3, and 4 trips. You must have 2 classes and the driver class. Be sure to use For-Each loops to list the fleet inventory, to find the specific car, and to print the individual trips. The miles and gallons must be added to the MPG array list using anonymous objects. Run the project and take a screenshot. Submission: the specified screenshots, and the root folder for the project Pay careful attention to the rubric for this assignment. Remember the standards that apply to every project. Note that you must use correct formatting in the code -- appropriate indentation is most important. You can use Shift-Alt-F to have NetBeans automatically format the code correctly. If the formatting is incorrect, it will be returned to you for changes with a grade of zero. Note: You need to submit the whole project for these assignments. In File Explorer, go to the location where you created the project. There will be a folder with the name of your project -- that is the root folder of the project. If you submit the root folder of the project, the instructor can run it on a different machine to grade it. If you don't submit the proper folder, it won't run on another machine, and the assignment will be marked with a zero.

    User: bell-kevin

    object-oriented-programming datc davis-tech davis-technical-college
  • bell-kevin / improvedinventoryprogram

    davis-tech,You created an inventory program in Ch 9 using an array with size of 2. As you’ve learned, when you don’t know how big an array needs to be, it’s better to use an array list. Make a COPY of the Ch 9 inventory project and change it to use an array list. Does anything need to change in the inventory class? Nothing – all the same variables and methods are needed. Does anything need to change in the driver class? No, because we are still working with a store that has inventory. The class for the store needs to change, from using an array of size 2 for the inventory items for the store, to an ArrayList of unknown size for the inventory items. Because the array had a known size, you probably used a For loop to go through the array to add inventory items. In this version, you need to ask the user if they want to continue adding more inventory items, and repeat that work if the answer is “yes”. In the Ch 9 version, you created a method to find an item in inventory, which returned the index number for that object in the inventory array. If the name of the array was “items”, you referenced an inventory item like this: items[k]. Since this version uses an array list, you can’t use the name with an index like that – you have to use the “get” method, items.get(k). You can chain other methods to it, like the sell method. You will probably need to make changes in the find and sell methods you created to access the elements in the array list instead of in the array. When the program runs, it should ask the user for inventory information, and ask if they want to continue to add more inventory, instead of asking for 2 items and no more. Thus the user can enter any number of items. Otherwise, the program should appear to behave exactly the same as it did in Ch 9. There could be more items added as appropriate – array lists make it very easy to increase the size of the array with no extra coding. Second part, purchasing items from inventory. This should behave exactly as seen previously, the only difference being the number of items to display in the inventory listing. Take a screenshot of your version of the sample session. Submission: the specified screenshots, and the root folder for the project Pay careful attention to the rubric for this assignment. Remember the standards that apply to every project. Note that you must use correct formatting in the code -- appropriate indentation is most important. You can use Shift-Alt-F to have NetBeans automatically format the code correctly. If the formatting is incorrect, it will be returned to you for changes with a grade of zero. Note: You need to submit the whole project for these assignments. In File Explorer, go to the location where you created the project. There will be a folder with the name of your project -- that is the root folder of the project. If you submit the root folder of the project, the instructor can run it on a different machine to grade it. If you don't submit the proper folder, it won't run on another machine, and the assignment will be marked with a zero.

    User: bell-kevin

    datc davis-tech davis-technical-college object-oriented-programming
  • bell-kevin / inputvalidationproject

    davis-tech,Create a project that asks the user for a minimum integer, then a maximum integer, then a value between those two numbers. The program needs to validate that the second number is greater than the first number, and it also needs to validate that the third number is between the first two numbers. Use 3 While loops, which will repeat over and over until the input value meets the criteria. Do not use any IF structures. Do not prompt for the input first, then test it in a While loop (priming the input) – instead, prompt for the data and read it from the scanner inside the loop. To do that, set the values for the 3 variables to something that is clearly invalid (like -1), so that the test in the While loop will always start out true. For example, if a variable named “minimum” is set to -1 when it is declared, then a While loop that tests if the minimum is less than 1 will be true, and the code inside the While loop will execute, which should prompt the user for the value, then read the data from the scanner. Note that there must be a title and your name at the top of the output. The prompts must allow the user to enter input to the right of the same line as the prompt. Note that the same prompt is repeated if the input was invalid. Once a valid number is input, the next prompt asks for new data. Be sure to include the minimum and maximum values in the prompt for the middle value. Echo the values as shown above once valid values have been entered. Take a screenshot of the running program that matches the sample session, and include the code above it. Run the program again and enter different values, with at least one invalid entry in each section, then take a screenshot of the results. Pay careful attention to the rubric for this assignment. Even if not specifically mentioned in the assignment, you are responsible for the following: Use descriptive names for all variables Add comments describing the use or meaning of variables Do NOT include literal values in any calculations, always use variables Always include a header in the output with a descriptive title and your name If asking for input, make sure the user types on the same line as the question Where sample sessions are provided, output from your project must match it Note that you must use correct formatting in the code -- appropriate indentation is most important. You can use Shift-Alt-F to have NetBeans automatically format the code correctly. If the formatting is incorrect, it will be returned to you for changes with a grade of zero. Submission: the specified screenshots and the root folder for the project Note: You need to submit the whole project for these assignments. In File Explorer, go to the location where you created the project. There will be a folder with the name of your project -- that is the root folder of the project. If you submit the root folder of the project, the instructor can run it on a different machine to grade it. If you don't submit the proper folder, it won't run on another machine, and the assignment will be marked with a zero.

    User: bell-kevin

    datc gpl3 gplv3 input-validation java validation while while-loop while-loops whileloops
  • bell-kevin / milespergallon

    davis-tech,Create a project that calculates miles per gallon for a given trip, and accumulates the miles and gallons to calculate an overall MPG for the vehicle. Create a class named MPG that includes private instance variables for miles, gallons, and mpg, which are doubles. Add class variables for totalMiles, totalGallons, and totalMPG, which are doubles, and numTrips, which is an integer. Create a constructor which accepts 2 double parameters, one for miles, one for gallons. Inside the constructor, set the instance variables for miles and gallons, and calculate the mpg. Add to the class variables for totalMiles and TotalGallons, and increment the number of trips. Create an instance method named displayCurrentMPG() which displays the MPG variable for a specific trip object. Create a class method named displayTotalMPG() which calculates and displays the overall MPG for all of the trip objects. The driver class will instantiate 4 trips, display the MPG for each trip, and display the overall MPG. For the sample session, use the following values: Trip1: miles = 320, gallons = 29 Trip2: miles = 325.8, gallons = 32.1 Trip3: miles = 412.5, gallons = 35 Trip4: miles = 345, gallons = 32.6 Note that these 4 trips test all the possible combinations of variable types – 2 integers, 2 doubles, 1 integer and 1 double, 1 double and 1 integer. It’s always good practice to test all possible situation. Be sure to match the formatting of the numbers. Once the program works as it should to match the sample session, run the project twice more, with different numbers for every trip, and take screenshots of the results.

    User: bell-kevin

    datc davis-tech davistech object-oriented-programming 2210 sdev sdev2210
  • bell-kevin / museumstorecafe

    davis-tech,In Competency Exercises, you demonstrate your skill and ability to use the programming principles you've learned in the current and previous modules. You must complete this assignment by yourself, much like a module exam. You can ask instructors for clarification about the project -- you can not ask instructors or other students for help with logic or coding. If you are struggling with the project, you can look at previous assignments where you did similar work, and you can review the pertinent sections in the book. These are the skills you practiced in this module and will now demonstrate: Arrays Array Lists For-Each loops Anonymous objects Module 4 Competency Exercise: Museum Store Cafe You have worked with the Museum in previous exercises. Here, you will work on inventory for the Museum Store Cafe. An inventory item has a name, category, price, and quantity. In the driver class, you will add items to the cafe inventory -- half will be instantiated and half will be anonymous. Display the entire menu using a For-Each loop. Ask the user what type of item they want to see. In the example below, the categories or types of items are entree, side, drink, and dessert. The user selects one category, and the program will print out any inventory item with that same category. Here is an example: M4 Comp The first 4 items were instantiated and then added to the array list. The second 4 items were added to the array list using anonymous objects. Code these directly in the driver class, no user interaction needed. You may choose the categories and items that are in the inventory. There must be at least 3 categories, and at least 8 items added to inventory. Make sure at least 4 are instantiated and then added, and at least 4 are anonymous objects. Do not load them in any kind of order, for example putting all of one category together. Run the project and take a screenshot. Remember the style rules that apply to all projects throughout this course. Even if not specifically mentioned in the assignments, you are responsible for the following: Use descriptive names for all variables Add comments describing the use or meaning of variables Do NOT include literal values in any calculations, always use variables Always include a header in the output with a descriptive title and your name If asking for input, make sure the user types on the same line as the question Where sample sessions are provided, output from your project must match it Note that you must use correct formatting in the code -- appropriate indentation is most important. You can use Shift-Alt-F to have NetBeans automatically format the code correctly. If the formatting is incorrect, it will be returned to you for changes with a grade of zero. Submission: screenshots and the root folder for the project

    User: bell-kevin

    object-oriented-programming datc davis-tech davis-technical-college museum-store-cafe
  • bell-kevin / testingrandomnumbers

    davis-tech,Testing Random Numbers Project SDEV 1060 Project. A senior developer is working on a project and has asked you to do some testing for him. One of the methods in his project creates a random number between supplied minimum and maximum values. He has written the method that will create that random number, run it a few times, and thinks it looks good, but just to make sure, he has asked you to thoroughly test the method. That method looks like this: In Java: public static int getRN(int min, int max) { Random rng = new Random( ); int answer = rng.nextInt((max - min + 1) + min); return answer; } In C#: public static int getRN(int min, int max) { Random rng = new Random( ); int answer = rng.Next(min, max + 1); return answer; } You put it into a small program to test it. Note that the program does not need any code in the main method, because you are this single method. Add it in the main class file, below the main method, not in a separate class. It would be a good practice to add code in the main class that asks the user for minimum and maximum values, or that has hard-coded min and max values, then calls this random number generator method, and displays the result. That is a good way to make sure the method runs as expected in your program and environment (it checks if you typed everything correctly). Since you are testing just the single method, and have no idea what it is being used for in the main method, there is no need for any code in the main method -- other than to test that your version of the method under test was typed correctly and will compile. In a test method, how can you assert that a random number is equal to a specific number? You can't, because the number should be random, so you can't predict the expected result. But you can assert that the random number falls within the range expected. You have written assertions with variables for expected and actual results, or literal values. You can also write expressions in the assertion. For example, if the method under test adds 2 numbers together and returns the sum, you could write an assertion like this: (Java) assertEquals(n1 + n2, actualResult) or (C#) Assert.AreEqual(n1 + n2, actualResult) The phrase "n1 + n2" is an expression that calculates the expected result in this example. Another example is checking for valid input, where the input number needs to be between 1 and 100 inclusive -- that means 1 and 100 are both valid results. How would you write that code to validate the input? It could look like this: if (inputValue >= 1 && inputValue <= 100) { do something } You can use that same type of expression in an assertion. That test would look like this as an assertion: (Java) assertTrue(inputValue >= 1 && inputValue <= 100) (C#) Assert.IsTrue(inputValue >= 1 && inputValue <= 100) If the relational tests (input value is greater than, equal, less than, etc) and the relational test (AND) are all true, the assertion passes, which means that the input value is valid, in this example. For random numbers, you can't specify an expected result, but you can check that the result is within the acceptable range. If it is true that the random number falls in the range, then the method worked correctly. The "arrange" stage of this test needs to know the range for the random numbers. What is the "act" stage of this test? You need to run the method from the other developer (above) and get the result, the random number. You learned how to test a static method in a previous assignment; you will do the same here. The method being tested returns the random number, which is the "actual" value that needs to be compared to the "expected" value. In this case, you will need to check if the random number falls within the expected range. For this assignment, that range is the numbers 20 to 29 inclusive. What is the "assert" stage of this test? You will assert that it is true that the actual result from the method is within the range. Be sure to add the optional message that will display if the test fails, and have it display the generated random number, which isn't in the range and caused the test to fail. Make sure you type the method exactly as you see it above as the static method in the main class. For this assignment, you want 10 possible random numbers starting at 20, so the possible numbers are 20, 21, 22, 23, 24, 25, 26, 27, 28, 29. Run this test. Does it pass or fail? The programmer who gave it to you said he had run it a few times and it looked good. Does it? If it does, will it suffice to run it a few times? No, that is not at all thorough for testing the happy path and edge values -- you have no way of being sure the edges were ever tested with random numbers. You need to test it many many times, repeatedly calling the random number method to check it. How do you get repetition in any program? Use a loop. A unit test is code just like all the code you've written in any program, with the addition of the Assert methods. You know how to write loops, you can add a loop within the unit test method. As part of the act step, use a For loop that runs many times (20 or 500 or 1,000 times, whatever seems appropriate); inside the loop, run the test you just created, where it calls the method and then asserts that it is true that the result is within the range given. If you have a bunch of assertions, if any one fails, none of the following ones will run. If you use a loop of 20 executions of the test, and it fails on the first one, it didn't run any others. You will not see reports like "passed 10 and failed 10" -- if it fails once, it's over. You have to keep fixing and running the code until all tests are successful. Run the test 200 times in a loop, to test the method multiple times. When you run the test, it should fail, there is an error in that code. See the discussion below to figure out the problem, fix it, and test it again. Keep working on it until all the tests are successful. Then run the test 5,000 times, to make sure it works as it should. Take a screenshot of your fixed code for the method, of your test code, and of the last successful test that ran 5,000 times. Submission: screenshots specified and the root folder for the project Discussion Random numbers have a minimum and maximum value. In some languages, you need to specify the number of numbers (Java) or scope (C#) and the starting value (Java) or shift (C#). The methods above have a phrase to get the number of numbers -- max - min + 1, that seems like it would be appropriate. In Java: The formula for generating random numbers is rng.nextInt(number of numbers). If there is a starting value, such as 1 or 50 or whatever, it needs to be added to the random number. So the formula for Java is: startingValue + rng.nextInt(number of numbers). It could also be written with the starting value at the end: rng.nextInt(number of numbers) + startingValue. Look carefully at the pattern provided above: rng.nextInt ( (max - min + 1) + min ) If we resolve some of that code, do the math in the inner parentheses, it becomes rng.nextInt ( (num) + min ) Once the math inside the inner parentheses is done, we can drop those parentheses, and this becomes rng.nextInt ( num + min ) which becomes rng.nextInt (someNumber) There is no term for the starting number to be added to this random number -- it was used inside of the parentheses for the parameter for rng.nextInt(). In the formula above, the number of numbers, inside the parentheses that follow rng.nextInt, does more than provide the number of numbers, it also adds the min or starting point to that number of numbers. If the random number generator is supposed to use 10 numbers that start with 20, that would be the numbers 20, 21, 22, 23, ... 29. The formula above says that the number of numbers is that 10 plus the min value of 20, so the number of numbers is now 30. And there is no starting value, so the random number generator will create a number from 0 to 30. Thus it is possible to get numbers that are less than the intended starting point of 20, and one higher than the intended max value of 29. How do you fix that pattern so the parameter for rng.nextInt() has only the number of numbers in it, and the starting value is separate, added to that random number? In C#: The pattern for random numbers in C# is a little different from the pattern for Java. They are so similar in so much code, but there is a difference for creating random numbers. There are several patterns, but the one intended here is: (int) rng.Next(starting value, ending value + 1) The rng.Next() method always returns a double, so it must have the cast to an integer at the beginning. There are 2 parameters, the shift (starting or min value) and the scope. That scope or max value will never be included in the possible random numbers, hence the "+1" in the pattern. If the code was: (int) rng.Next(20, 30) it would create a random number with the smallest possible number of 20 (the starting point) and the highest number will be 29, because it cannot go to 30. That value of 30 is the next integer after the highest one allowed. So this pattern also uses min and max values, but the shift and scope are represented differently. If min is 20 and max is 30, look at how the code provided works out: (int) rng.Next(max - min + 1, min) becomes (int) rng.Next( 30 - 20 + 1, 20) which becomes (int) rng.Next(11, 20) That means that the smallest number can be 11, and the largest number is one less than 20, or 19. The range of 11 to 19 is nothing at all like the intended range of 10 numbers starting at 20, or 20 to 29. None of the values generated with that pattern in the code provided would be valid. How do you fix the pattern in the code provided above? == We're Using GitHub Under Protest == This project is currently hosted on GitHub. This is not ideal; GitHub is a proprietary, trade-secret system that is not Free and Open Souce Software (FOSS). We are deeply concerned about using a proprietary system like GitHub to develop our FOSS project. We have an [open {bug ticket, mailing list thread, etc.} ](INSERT_LINK) where the project contributors are actively discussing how we can move away from GitHub in the long term. We urge you to read about the [Give up GitHub](https://GiveUpGitHub.org) campaign from [the Software Freedom Conservancy](https://sfconservancy.org) to understand some of the reasons why GitHub is not a good place to host FOSS projects. If you are a contributor who personally has already quit using GitHub, please [check this resource](INSERT_LINK) for how to send us contributions without using GitHub directly. Any use of this project's code by GitHub Copilot, past or present, is done without our permission. We do not consent to GitHub's use of this project's code in Copilot. ![Logo of the GiveUpGitHub campaign](https://sfconservancy.org/img/GiveUpGitHub.png)

    User: bell-kevin

    datc davis-tech davis-technical-college kaysville random-number-generator sdev unit-testing utah object-oriented-programming
  • bell-kevin / time

    davis-tech,When asking a user for a time, you might get several different formats of input – just the hour, the hour and minutes, the hour and minutes and seconds, an indication of “am” vs “pm”. In this project, the Time class will have overloaded constructors, one for each of those possible types of input, and most of the constructors will call the primary constructor. If the input were perfect, there would be values for hour, minutes, and seconds, so that constructor with 3 parameters is the main or primary one. If the input has only hours and minutes, then the constructor with 2 parameters will assign a value of 0 to the seconds and call the primary constructor with all 3 values. If the input has only hours, then the constructor with 1 parameter will assign a value of 0 to the minutes and to the seconds, then call the primary constructor with all 3 values. Only the primary constructor with 3 parameters will assign values to the instance variables. If there is an additional parameter for “am” or “pm”, use a constructor with 4 parameters – hours, minutes, seconds, and indicator. If the indicator is “pm”, add 12 to the hours to convert to a 24-hour clock. If the input is 4 PM, switch it to 16 hours. Include a method to display the time with colons separating the units. If the time is 1 hour, 22 minutes, and 35 seconds, print it as 1:22:35. Run the project to match the sample session and take a screenshot. Change all of the input in the driver class, run it again, and take a screenshot.

    User: bell-kevin

    datc davis-tech object-oriented-programming
  • bell-kevin / usedcarautolot

    davis-tech,In this project, simulate a used car auto lot. There are 3 types of vehicles – cars, trucks, and another one that you choose. For these instructions, that choice is a Minivan – you may use that or select another type of vehicle. The output from this project will first list all of the inventory, then ask the user what type of car they are interested. It will display all of the vehicles that match the user's choice.

    User: bell-kevin

    car truck van davis-tech davis-technical-college utah shopping
  • bell-kevin / workingwithanarraylist

    davis-tech,Create a project that instantiates an ArrayList of Strings. Follow the directions below for adding and removing data from the ArrayList, then print out the results. You do not need to ask the user for any of this data, type it directly into the code of the main class. Be sure to print out the usual header first, "Chapter 10 Array Lists by Student Name” with a blank line after. Directions for the ArrayList: Add your name Add “games” Add your favorite hobby Set “enjoys” as the value in position 1 Add your favorite holiday Remove the item in position 3 Add your birthday month Set “programming” as the value in position 2 Remove the item at the end of the list (you’ll need to know the size of the list to do this) Print the list Take a screenshot of the code with the output below it.

    User: bell-kevin

    arraylist object-oriented-programming array-list datc davis-tech davis-technical-college

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.