Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

java .. . Oakland Community Collegex Program 1 - Ohject-Oriented x + C o aklandco.desire2learn.com/d21/ms/dropbox/user/folder_submit_files.d2l2db=127542&grpid=0&isprv=0&bp=0&pu=111076 Instructions Create a NetBeans project named TestTown, and in that

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedjava

.. . Oakland Community Collegex Program 1 - Ohject-Oriented x + C o aklandco.desire2learn.com/d21/ms/dropbox/user/folder_submit_files.d2l2db=127542&grpid=0&isprv=0&bp=0&pu=111076 Instructions Create a NetBeans project named TestTown, and in that project create a class Town that corresponds to the following UML class diagram: Town -name : String -population : int +DEFAULT NAME : String +MIN POPULATION : int +MAX POPULATION: int +Town() +Town(String) +Town(String, int) +setName(String name) : void +getName(): String +setPopulation(int pop) : void +getPopulation(): int +doubleThePopulation(): int Cancellaton : int und Submit Chrome File Edit View History Bookmarks People Tab Window Help * 99% Fri 10:58 AM Q E ... Oakland Community College X Program 1 - Object-Oriented PX C o aklandcc.desire2learn.com/d21/Ims/dropbox/user/folder_submit_files.d21?db=127542&grpid=0&isprv=0&bp=0&ou=111076 +halve ThePopulaton(): int +toString(): String The TestTown's main method fully tests one or more Town objects: Test Town +main(String [] args) : void Notes: 1. The name must be a valid string (i.e., it cannot be null). If there is an attempt to set the name to null then the name should instead be set to the string "*** No Name 2. The population must be between 1 and 100,000. If there is an attempt to set the population to something larger than 100,000 then set the population to the maximum value of 100,000. If there is an attempt to set the population to something below 1, then set the population to 1. These rules should be applied to the constructor, set methods and methods such as doubleThePopulation and halveThePopulation. 3. If a constructor does not a specify a name or population, then in that case use the DEFAULT NAME for name and one half of the MAY DODILLATION ia 50 nnn Submit Cancel Jat can alter the value of an instance variables (.e., name and Catania Heas.com ... Oakland Community College x 9 Pragram 1 - Object-Oriented P x + + C o oaklandco.desire2learn.com/d21/Ims/dropbox/user/folder_submit_files.d212db=127542&grpid=0&isprv=0&bp=0&ou=111076 +halve ThePopulaton() : int +toString(): String The TestTown's main method fully tests one or more Town objects: Test Town +main(String I args) : void Notes: 1. The name must be a valid string (i.e., it cannot be null). If there is an attempt to set the name to null then the name should instead be set to the string "*** No Name 2. The population must be between 1 and 100,000. If there is an attempt to set the population to something larger than 100,000 then set the population to the maximum value of 100,000. If there is an attempt to set the population to something below 1, then set the population to 1. These rules should be applied to the constructor, set methods and methods such as doubleThePopulation and halveThePopulation. 3. If a constructor does not a specify a name or population, then in that case use the DEFALIIT NAME for name and one half of the MAY DODILLATION. 50 noi Submit Cancellat can alter the value of an instance variables e, name and .. . Oakland Community Collegex Program 1 - Ohject-Oriented x + C o aklandcc.desire2learn.com/d21/ms/dropbox/user/folder_submit_files.d2l2db=127542&grpid=0&isprv=0&bp=0&ou=111076 3. If a constructor does not a specify a name or population, then in that case use the DEFAULT NAME for name and one half of the MAX POPULATION (i.c., 50,000) for the population. Test each method that can alter the value of an instance variables (.e., name and population) for setting the instance variable to: 1. Several typical values 2. Boundary values 3. Values just before each boundary value 4. Values just after each boundary value 5. Explicitly bad values 5. For example, for Note 3, for set Population you might test for setting the population to: 1. Several typical values: 33, 2000, 58,000 2. Boundary values: 1, 100,000 3. Values just before each boundary value: 2 and 99,000 4. Values just after each boundary value: 0, 100,001 5. Explicitly bad values: -1, -100, 200,000, 300,000 6. The toString() method should create a string of this format: "Farmington has a population of 97,500". I'd suggest using String.format to get the comma to show up after every three digits in the population. 7. Upload to D2L just these two files (do not ZIP the files -- just upload them separately): Town.java and TestTown.java Here is a partial solution to the main method in TestTown package testtown; Bauthor partial solution Submit Cancel ... Oakland Community College x 9 Pragram 1 - Object-Oriented P x + C o aklandcc.desire2learn.com/d21/ms/dropbox/user/folder_submit_files.d2l2db=127542&grpid=0&isprv=0&bp=0&ou=111076 4. Values just after each boundary value: 0, 100,001 5. Explicitly bad values: -1, -100, 200,000, 300,000 6. The toString() method should create a string of this format: "Farmington has a population of 97,500". I'd suggest using String.format to get the comma to show up after every three digits in the population. 7. Upload to D2L just these two files (do not ZIP the files -- just upload them separately): Town.java and TestTown.java Here is a partial solution to the main method in TestTown: package teat.t.ow; author partial solution version January 11, 2018 Test driver for the Town class. public clase Test Town { paran arga the command line arguments public static void main(String[] args) { Towr. farnir.gton - new own("Parmington", 97 500); System.out.println(Earningtor..toString ); essert farmington.get Population) -- 97_500: "Constuctor set pop to 97,500"; Asaert farmington.getName().equals("Farmington) - "Constructor Bet name to Earnington, farmington.SetPopulation (98 111) naart tarmington.getTagulation) == 9H311 Tetrap set pop to 98,111'; farmington.doubleThePopulation(); // should only go to max of 100,000 assert farmington.getPopulation) -- 100_0001 double pop to max of 100,000"; Submit Cancel

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions