Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

An abstraction of an array?

Tags:

java

this is for a assignment, and one of the tasks is to create a abstraction of a array, does it mean that i am declaring a array that's abstract here, if so how would i declare it

private abstract Array<TYPE> Disk = new Array<TYPE>()

? something like that? or is it impossible to create a abstract array and its talking about making a class abstract and inserting a array in that class

// Build an abstraction of an array of integers on disk. If the file exists, * it should be opened and its length calculated (size parameter is ignored). * If the file doesn't exist, it should be created and size zeros should be * written to the file. ^^ goal here

please don't answer or give me any code, other than a yes or no to declaring that array and wether it would work


1 Answers

The given input is a bit sparse, so I can only guess what to do.

An abstraction can be interpreted in multiple ways.

  • To "create an abstract array" is not building an abstraction. Usually an abstract method is used to signify, that this method has no implementation. In this context I think it doesn't make any sense.
  • The same with making an abstract class.

or, as I would argue:

  • You have to create an abstraction of something, which means you want to hide details and/or information. In your case, you have an array of integers, and you want to store it on disk. Furthermore, you have some operations you want to apply to this. This gives you an abstraction. You define an interface (operations) and hide all the rest (array of ints, store on disk). In other words, you abstracted all the details, and provided some easy to use interface.

So In my opinion, you have to create a class having the asked operations, and implement some store/load methods, and return the appropriate results.

like image 149
duedl0r Avatar answered Dec 04 '25 01:12

duedl0r



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!